mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
fix(tohtml): disable modeline #32822
Problem: Running :TOhtml with a file containing modeline may generate an invalid modeline in the output. Solution: Add `<!-- vim: set nomodeline: -->` to the output. Use vi-compatible modeline format ("set foo:"), to avoid the trailing `-->` being treated as part of the modeline.
This commit is contained in:
@@ -1372,6 +1372,7 @@ local function win_to_html(winid, opt)
|
|||||||
state_generate_style(state)
|
state_generate_style(state)
|
||||||
|
|
||||||
local html = {}
|
local html = {}
|
||||||
|
table.insert(html, '<!-- vim: set nomodeline: -->')
|
||||||
extend_html(html, function()
|
extend_html(html, function()
|
||||||
extend_head(html, global_state)
|
extend_head(html, global_state)
|
||||||
extend_body(html, function()
|
extend_body(html, function()
|
||||||
|
@@ -159,6 +159,7 @@ local function test_generates_html(guifont, expect_font)
|
|||||||
|
|
||||||
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||||
eq({
|
eq({
|
||||||
|
'<!-- vim: set nomodeline: -->',
|
||||||
'<!DOCTYPE html>',
|
'<!DOCTYPE html>',
|
||||||
'<html>',
|
'<html>',
|
||||||
'<head>',
|
'<head>',
|
||||||
@@ -212,6 +213,7 @@ describe(':TOhtml', function()
|
|||||||
n.command('2,2TOhtml')
|
n.command('2,2TOhtml')
|
||||||
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||||
eq({
|
eq({
|
||||||
|
'<!-- vim: set nomodeline: -->',
|
||||||
'<!DOCTYPE html>',
|
'<!DOCTYPE html>',
|
||||||
'<html>',
|
'<html>',
|
||||||
'<head>',
|
'<head>',
|
||||||
|
Reference in New Issue
Block a user