mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +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)
|
||||
|
||||
local html = {}
|
||||
table.insert(html, '<!-- vim: set nomodeline: -->')
|
||||
extend_html(html, function()
|
||||
extend_head(html, global_state)
|
||||
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())
|
||||
eq({
|
||||
'<!-- vim: set nomodeline: -->',
|
||||
'<!DOCTYPE html>',
|
||||
'<html>',
|
||||
'<head>',
|
||||
@@ -212,6 +213,7 @@ describe(':TOhtml', function()
|
||||
n.command('2,2TOhtml')
|
||||
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||
eq({
|
||||
'<!-- vim: set nomodeline: -->',
|
||||
'<!DOCTYPE html>',
|
||||
'<html>',
|
||||
'<head>',
|
||||
|
Reference in New Issue
Block a user