summaryrefslogtreecommitdiff
path: root/macros/generic/markdown/markdown.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic/markdown/markdown.dtx')
-rw-r--r--macros/generic/markdown/markdown.dtx47
1 files changed, 32 insertions, 15 deletions
diff --git a/macros/generic/markdown/markdown.dtx b/macros/generic/markdown/markdown.dtx
index 71c06b8154..0cf9f4f9ac 100644
--- a/macros/generic/markdown/markdown.dtx
+++ b/macros/generic/markdown/markdown.dtx
@@ -535,8 +535,9 @@ The [Markdown package][pkg] converts [markdown][] markup to \TeX{} commands. The
functionality is provided both as a Lua module and as plain \TeX{}, \LaTeX{}, and
\Hologo{ConTeXt} macro packages that can be used to directly typeset \TeX documents
containing markdown markup. Unlike other convertors, the Markdown package
-makes it easy to redefine how each and every markdown element is rendered.
-Creative abuse of the markdown syntax is encouraged. ;-)
+does not require any external programs, and makes it easy to redefine how each
+and every markdown element is rendered. Creative abuse of the markdown
+syntax is encouraged. ;-)
[markdown]: https://daringfireball.net/projects/markdown/basics/
(Daring Fireball: Markdown Basics)
@@ -569,11 +570,11 @@ documentation][techdoc].
% \fi
% \begin{macrocode}
local metadata = {
- version = "2.8.1",
+ version = "2.8.2",
comment = "A module for the conversion from markdown to plain TeX",
author = "John MacFarlane, Hans Hagen, Vít Novotný",
copyright = {"2009-2016 John MacFarlane, Hans Hagen",
- "2016-2019 Vít Novotný"},
+ "2016-2020 Vít Novotný"},
license = "LPPL 1.3"
}
@@ -5659,8 +5660,8 @@ pdftex --shell-escape document.tex
%
% \end{markdown}
% \begin{macrocode}
-\def\markdownLastModified{2019/04/30}%
-\def\markdownVersion{2.8.1}%
+\def\markdownLastModified{2020/03/20}%
+\def\markdownVersion{2.8.2}%
% \end{macrocode}
% \par
% \begin{markdown}
@@ -5796,7 +5797,7 @@ interfaces.
% of the document being typeset.
%
% The expansion of this macro must not contain quotation marks (`"`) or
-% backslash symbols (`extbackslash`). Mind that \TeX{} engines tend to
+% backslash symbols (`\`). Mind that \TeX{} engines tend to
% put quotation marks around \m{jobname}, when it contains spaces.
%
% \end{markdown}
@@ -6939,6 +6940,8 @@ following content:
\catcode`\^^A=14
\global\def\markdownRendererImage#1#2#3#4{^^A
\immediate\write18{^^A
+```
+``` sh
if printf '%s' "#3" | grep -q ^http; then
OUTPUT="$(printf '%s' "#3" | md5sum | cut -d' ' -f1).^^A
$(printf '%s' "#3" | sed 's/.*[.]//')";
@@ -6950,6 +6953,8 @@ following content:
else
printf '%s%%' "#3" > \jobname.fetched;
fi^^A
+```
+``` tex
}^^A
{^^A
\everyeof={\noexpand}^^A
@@ -13701,6 +13706,7 @@ function M.writer.new(options)
% \begin{macrocode}
function self.verbatim(s)
if not self.is_writing then return "" end
+ s = string.gsub(s, '[\r\n%s]*$', '')
local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim")
return {"\\markdownRendererInputVerbatim{",name,"}"}
end
@@ -13716,6 +13722,7 @@ function M.writer.new(options)
% \begin{macrocode}
function self.fencedCode(i, s)
if not self.is_writing then return "" end
+ s = string.gsub(s, '[\r\n%s]*$', '')
local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim")
return {"\\markdownRendererInputFencedCode{",name,"}{",i,"}"}
end
@@ -14978,7 +14985,8 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline
%
% \end{markdown}
% \begin{macrocode}
- larsers.Str = parsers.normalchar^1 / writer.string
+ larsers.Str = (parsers.normalchar * (parsers.normalchar + parsers.at)^0)
+ / writer.string
larsers.Symbol = (parsers.specialchar - parsers.tightblocksep)
/ writer.string
@@ -15650,7 +15658,14 @@ if metadata.version ~= md.metadata.version then
"markdown.lua " .. md.metadata.version .. ".")
end
local convert = md.new(options)
-local output = convert(input:gsub("\r\n?", "\n"))
+% \end{macrocode}
+% \begin{markdown}
+% Since the Lua converter expects \acro{unix} line endings, normalize the
+% input. Also add a line ending at the end of the file in case the input file
+% has none.
+% \end{markdown}
+% \begin{macrocode}
+local output = convert(input:gsub("\r\n?", "\n") .. "\n")
if output_filename then
local output_file = io.open(output_filename, "w")
@@ -16016,7 +16031,10 @@ local convert = md.new(\markdownLuaOptions)
|markdownInfo{The ending token sequence was found}@
|immediate|closeout|markdownOutputFileStream@
|endgroup@
- |markdownInput|markdownOptionInputTempFileName@
+ |markdownInput{@
+ |markdownOptionOutputDir@
+ /|markdownOptionInputTempFileName@
+ }@
#2}@
|fi@
% \end{macrocode}
@@ -16285,16 +16303,15 @@ local convert = md.new(\markdownLuaOptions)
|closein|markdownInputFileStream
|markdownLuaExecute{%
|markdownPrepare
- local input = assert(io.open("%
- |markdownOptionOutputDir
- /#1", "r"):read("*a"))
+ local input = assert(io.open("#1", "r"):read("*a"))
% \end{macrocode}
% \begin{markdown}
% Since the Lua converter expects \acro{unix} line endings, normalize the
-% input.
+% input. Also add a line ending at the end of the file in case the input file
+% has none.
% \end{markdown}
% \begin{macrocode}
- print(convert(input:gsub("\r\n?", "\n")))}}%
+ print(convert(input:gsub("\r\n?", "\n") .. "\n"))}}%
|endgroup
% \end{macrocode}
% \iffalse