Discussion:
[Docutils-users] add <meta> tag to rst2html?
Oleksandr Gavenko
2016-02-22 00:15:33 UTC
Permalink
Modern HTML5 text usually have:

<meta name=viewport content="width=device-width, initial-scale=1">

in <head>.

I can't understand how can I pass this line to resulted template.

In ``rst2html --help`` there is:

HTML-Specific Options
---------------------
--template=<file> Specify the template file (UTF-8 encoded). Default is
"/usr/share/docutils/writers/html4css1/template.txt".

``template.txt`` is:

%(head_prefix)s
%(head)s
%(stylesheet)s
%(body_prefix)s
%(body_pre_docinfo)s
%(docinfo)s
%(body)s
%(body_suffix)s

What changes make to template in order to include additional <meta> tag?

*PS* I can precess HTML files with sed as quick solution.
--
http://defun.work/


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Oleksandr Gavenko
2016-02-22 08:53:53 UTC
Permalink
Post by Oleksandr Gavenko
<meta name=viewport content="width=device-width, initial-scale=1">
in <head>.
I can't understand how can I pass this line to resulted template.
HTML-Specific Options
---------------------
--template=<file> Specify the template file (UTF-8 encoded). Default is
"/usr/share/docutils/writers/html4css1/template.txt".
%(head_prefix)s
%(head)s
%(stylesheet)s
%(body_prefix)s
%(body_pre_docinfo)s
%(docinfo)s
%(body)s
%(body_suffix)s
Makefile rule:

RST_WARNING_FLAGS := --halt warning
RST_RENDER_FLAGS := --strip-comments --embed-stylesheet --no-xml-declaration --math-output=MathJax
RST_FLAGS := $(RST_WARNING_FLAGS) $(RST_RENDER_FLAGS)

$(HTML_DIR)/%.html: %.rst HEADER.rst rst.css rst.tmpl $(MAKEFILE_LIST) | $(HTML_DIR)
$(RST2HTML) $(RST_FLAGS) --stylesheet=rst.css --template=rst.tmpl $*.rst
$@

rst.tmpl:

<!DOCTYPE html>
<html>
<head>
<meta name=viewport content="width=device-width, initial-scale=1">
%(head)s
%(stylesheet)s
%(body_prefix)s
%(body_pre_docinfo)s
%(docinfo)s
%(body)s
%(body_suffix)s

I replace %(head_prefix)s with above tags. This makes generated files HTML 5
compliant.

Firefox source browser warn (highlight by red) default substitution:

<?xml version="1.0" encoding="utf-8" ?> ## Attempt to use XML
## processing instructions in HTML

<!DOCTYPE html PUBLIC ## Almost standard mode doctype
"-//W3C//DTD XHTML 1.0 Transitional//EN" ## Expected <!DOCTYPE html>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Problem resolved.
--
http://defun.work/


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Loading...