summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/markdown
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/generic/markdown')
-rw-r--r--Master/texmf-dist/source/generic/markdown/markdown.dtx240
1 files changed, 169 insertions, 71 deletions
diff --git a/Master/texmf-dist/source/generic/markdown/markdown.dtx b/Master/texmf-dist/source/generic/markdown/markdown.dtx
index 6ad42a46b26..4685ed3ee66 100644
--- a/Master/texmf-dist/source/generic/markdown/markdown.dtx
+++ b/Master/texmf-dist/source/generic/markdown/markdown.dtx
@@ -965,20 +965,28 @@ requirements.
Installation
------------
-If Markdown is not included in your \TeX{} distribution, you will need to
-install it.
+If the Markdown package is not included in your \TeX{} distribution, you will
+need to install it.
-First, download the package from the repository using Git:
+From [Releases][], download [an archive `markdown.zip` for this version of the
+Markdown package (\markdownShortVersion{})][this-release] or a different version
+that you wish to install. Then, unzip the archive. If you downloaded an archive
+for a different version of the Markdown package, you should now locate a file
+named `markdown.html` with the user manual for that version, open it, and
+follow the installation steps in it rather than the steps from this manual.
+
+ [releases]: https://github.com/witiko/markdown/releases (Releases - witiko/markdown)
+ [this-release]: https://github.com/witiko/markdown/releases/download/\markdownShortVersion{}/markdown.zip (Release \markdownShortVersion{} - witiko/markdown)
+
+Alternatively, download the package from the repository using Git, enter the
+directory named `markdown` and run the `make base` command using GNU Make:
``` sh
git clone https://github.com/witiko/markdown
-``````
-Next, enter the directory named `markdown` and run the `make base` command using
-GNU Make:
-``` sh
cd markdown
make base
``````
-This should produce the following files:
+
+Either of the two abovelisted approaches should produce the following files:
* `markdown.lua`: The Lua module
* `libraries/markdown-tinyyaml.lua`: An external library for reading \acro{yaml}
@@ -1039,6 +1047,8 @@ This is where the individual files should be placed:
* `./markdownthemewitiko_markdown_defaults.sty`
* `./t-markdownthemewitiko_markdown_defaults.tex`
+The file `markdown.tex` *must* be placed in a directory named `markdown`.
+
%</manual>
%<*lua>
% \fi
@@ -1691,9 +1701,6 @@ In this section, I will describe the individual parts of the Markdown package.
Each part will be shown by example, leaving the implementation details to the
[technical documentation][techdoc].
- [techdoc]: https://mirrors.ctan.org/macros/generic/markdown/markdown.pdf
- (A Markdown Interpreter for \TeX{})
-
/markdown-interfaces.md
/markdown-options.md
/markdown-tokens.md
@@ -2502,11 +2509,12 @@ defaultOptions.eagerCache = false
: Every call to the function \luamref{new}`(options)` will produce a new
conversion function that will not be cached. This is slower than
caching conversion functions and may expose bugs related to memory
- leaks in the creation of conversion functions, see also issue [#226][1].
+ leaks in the creation of conversion functions, see also issue
+ [#226][issue-226].
This was the default behavior until version 3.0.0 of the Markdown package.
- [1]: https://github.com/witiko/markdown/pull/226#issuecomment-1599641634
+ [issue-226]: https://github.com/witiko/markdown/pull/226#issuecomment-1599641634
% \end{markdown}
% \iffalse
@@ -8182,10 +8190,6 @@ following text:
> Here is a note reference,[^1] and another.[^longnote]
>
-> [^1]: Here is the note.
->
-> [^longnote]: Here's one with multiple blocks.
->
> Subsequent paragraphs are indented to show that they
> belong to the previous note.
>
@@ -8236,10 +8240,6 @@ following text:
> Here is a note reference,[^1] and another.[^longnote]
>
-> [^1]: Here is the note.
->
-> [^longnote]: Here's one with multiple blocks.
->
> Subsequent paragraphs are indented to show that they
> belong to the previous note.
>
@@ -8528,7 +8528,7 @@ defaultOptions.rawAttribute = false
%
: true
- : Enable [relative references][1] in autolinks:
+ : Enable [relative references][rfc3986] in autolinks:
``` md
I conclude in Section <#conclusion>.
@@ -8544,7 +8544,7 @@ defaultOptions.rawAttribute = false
: Disable relative references in autolinks.
- [1]: https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
+ [rfc3986]: https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
% \end{markdown}
% \iffalse
@@ -10486,9 +10486,9 @@ luatex document.tex
A PDF document named `document.pdf` should be produced and contain the
following text:
-> \\(E=mc^2\\)
+> \(E=mc^2\)
>
-> \\[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\\]
+> \[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\]
##### Lua CLI Example {.unnumbered}
@@ -10528,13 +10528,13 @@ script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
following text:
-> \\\(E=mc^2\\)
->
-> \\\[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\\]
->
> \\(E=mc^2\\)
>
> \\[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\\]
+>
+> \(E=mc^2\)
+>
+> \[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\]
##### Plain \TeX{} Example {.unnumbered}
@@ -10559,9 +10559,9 @@ luatex document.tex
A PDF document named `document.pdf` should be produced and contain the
following text:
-> \\(E=mc^2\\)
+> \(E=mc^2\)
>
-> \\[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\\]
+> \[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\]
##### \LaTeX{} Example {.unnumbered}
@@ -10587,9 +10587,9 @@ lualatex document.tex
A PDF document named `document.pdf` should be produced and contain the
following text:
-> \\(E=mc^2\\)
+> \(E=mc^2\)
>
-> \\[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\\]
+> \[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\]
##### \Hologo{ConTeXt} Example {.unnumbered}
@@ -10615,9 +10615,9 @@ context --luatex document.tex
A PDF document named `document.pdf` should be produced and contain the
following text:
-> \\(E=mc^2\\)
+> \(E=mc^2\)
>
-> \\[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\\]
+> \[\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\]
%</manual-options>
%<*tex>
@@ -19454,7 +19454,7 @@ following content:
\input markdown
\def\markdownOptionTexMathDollars{true}
\def\markdownRendererInlineMath#1{$#1\dots$}
-\def\markdownRendererDisplayMath#1{$$#1\eqno(1)$$}
+\def\markdownRendererDisplayMath#1{$$#1\nonumber$$}
\markdownBegin
$E=mc^2$
@@ -19471,7 +19471,7 @@ following text:
> $E=mc^2\dots$
>
-> $$\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\eqno(1)$$
+> $$\hat{f} \left ( \xi \right )= \int_{-\infty}^{\infty} f\left ( x \right ) e^{-i2\pi \xi x} dx\nonumber$$
##### \LaTeX{} Example {.unnumbered}
@@ -27660,19 +27660,21 @@ parsers.link_text = parsers.lbracket
- (parsers.newline + parsers.lbracket + parsers.rbracket + parsers.blankline^2))))^0)
* parsers.rbracket
+parsers.link_label_body = -#(parsers.sp * parsers.rbracket)
+ * #((parsers.any - parsers.rbracket)^-999 * parsers.rbracket)
+ * Cs((parsers.alphanumeric^1
+ + parsers.inticks
+ + parsers.autolink
+ + V("InlineHtml")
+ + ( parsers.backslash * parsers.backslash)
+ + ( parsers.backslash * (parsers.lbracket + parsers.rbracket)
+ + V("NoSoftLineBreakSpace")
+ + V("NoSoftLineBreakEndline")
+ + (parsers.any
+ - (parsers.newline + parsers.lbracket + parsers.rbracket + parsers.blankline^2))))^1)
+
parsers.link_label = parsers.lbracket
- * -#(parsers.sp * parsers.rbracket)
- * #((parsers.any - parsers.rbracket)^-999 * parsers.rbracket)
- * Cs((parsers.alphanumeric^1
- + parsers.inticks
- + parsers.autolink
- + V("InlineHtml")
- + ( parsers.backslash * parsers.backslash)
- + ( parsers.backslash * (parsers.lbracket + parsers.rbracket)
- + V("NoSoftLineBreakSpace")
- + V("NoSoftLineBreakEndline")
- + (parsers.any
- - (parsers.newline + parsers.lbracket + parsers.rbracket + parsers.blankline^2))))^1)
+ * parsers.link_label_body
* parsers.rbracket
parsers.inparens_url = P{ parsers.lparent
@@ -28562,6 +28564,9 @@ function M.reader.new(writer, options)
-- List of references defined in the document
local references
+ -- List of note references defined in the document
+ parsers.rawnotes = {}
+
% \end{macrocode}
% \par
% \begin{markdown}
@@ -28599,6 +28604,19 @@ function M.reader.new(writer, options)
return references[self.normalize_tag(tag)]
end
+% \end{macrocode}
+% \par
+% \begin{markdown}
+%
+% The \luamdef{reader->lookup_note_reference} method looks up a
+% note reference with label `tag`.
+%
+% \end{markdown}
+% \begin{macrocode}
+ function self.lookup_note_reference(tag)
+ return parsers.rawnotes[self.normalize_tag(tag)]
+ end
+
parsers.title_s_direct_ref = parsers.squote
* Cs((parsers.html_entities
+ (parsers.anyescaped - parsers.squote - parsers.blankline^2))^0)
@@ -28669,15 +28687,49 @@ function M.reader.new(writer, options)
+ #parsers.link_text
* Cg(Cc("link_text"), "link_type")
+ parsers.note_opening = #(parsers.circumflex * parsers.shortcut_link)
+ * Cg(Cc("note_inline"), "link_type")
+
+ parsers.raw_note_opening = #( parsers.lbracket
+ * parsers.circumflex
+ * parsers.link_label_body
+ * parsers.rbracket)
+ * Cg(Cc("raw_note"), "link_type")
+
+ local inline_note_element = Cg(Cc("note"), "element")
+ * parsers.note_opening
+ * Cg(parsers.circumflex * parsers.lbracket, "content")
+
+ local image_element = Cg(Cc("image"), "element")
+ * parsers.image_opening
+ * Cg(parsers.exclamation * parsers.lbracket, "content")
+
+ local note_element = Cg(Cc("note"), "element")
+ * parsers.raw_note_opening
+ * Cg(parsers.lbracket * parsers.circumflex, "content")
+
+ local link_element = Cg(Cc("link"), "element")
+ * parsers.link_opening
+ * Cg(parsers.lbracket, "content")
+
+ local opening_elements = parsers.fail
+
+ if options.inlineNotes then
+ opening_elements = opening_elements + inline_note_element
+ end
+
+ opening_elements = opening_elements + image_element
+
+ if options.notes then
+ opening_elements = opening_elements + note_element
+ end
+
+ opening_elements = opening_elements + link_element
+
parsers.link_image_opening = Ct( Cg(Cc("delimiter"), "type")
* Cg(Cc(true), "is_opening")
* Cg(Cc(false), "is_closing")
- * ( Cg(Cc("image"), "element")
- * parsers.image_opening
- * Cg(parsers.exclamation * parsers.lbracket, "content")
- + Cg(Cc("link"), "element")
- * parsers.link_opening
- * Cg(parsers.lbracket, "content")))
+ * opening_elements)
parsers.link_image_closing = Ct( Cg(Cc("delimiter"), "type")
* Cg(Cc("link"), "element")
@@ -28750,7 +28802,7 @@ function M.reader.new(writer, options)
local value = t[i]
if value.type == "delimiter" and
value.is_opening and
- (value.element == "link" or value.element == "image")
+ (value.element == "link" or value.element == "image" or value.element == "note")
and not value.removed then
if value.is_active then
return i
@@ -28893,6 +28945,15 @@ function M.reader.new(writer, options)
rendered = writer.image(mapped, reference.url, reference.title, reference.attributes)
end
+ if (t[opening_index].element == "note") then
+ if (t[opening_index].link_type == "note_inline") then
+ rendered = writer.note(mapped)
+ end
+ if (t[opening_index].link_type == "raw_note") then
+ rendered = writer.note(reference)
+ end
+ end
+
t[opening_index].rendered = rendered
delete_parsed_content_in_range(t, opening_index + 1, closing_index)
empty_content_in_range(t, opening_index, closing_index)
@@ -28958,7 +29019,7 @@ function M.reader.new(writer, options)
% \end{macrocode}
% \begin{markdown}
%
-% Resolve an inline link [a](b "c") from the delimiters at `opening_index` and `closing_index`
+% Resolve an inline link `[a](b "c")` from the delimiters at `opening_index` and `closing_index`
% within a delimiter table `t`. Here, compared to other types of links, no reference definition is needed.
%
% \end{markdown}
@@ -28971,7 +29032,20 @@ function M.reader.new(writer, options)
% \end{macrocode}
% \begin{markdown}
%
-% Resolve a shortcut link [a] from the delimiters at `opening_index` and `closing_index` within a delimiter table `t`.
+% Resolve an inline note `^[a]` from the delimiters at `opening_index` and `closing_index`
+% within a delimiter table `t`.
+%
+% \end{markdown}
+% \begin{macrocode}
+ local function resolve_note_inline_link(t, opening_index, closing_index)
+ local inline_content = resolve_inline_following_content(t, closing_index, false, false)
+ render_link_or_image(t, opening_index, closing_index, closing_index, inline_content)
+ end
+
+% \end{macrocode}
+% \begin{markdown}
+%
+% Resolve a shortcut link `[a]` from the delimiters at `opening_index` and `closing_index` within a delimiter table `t`.
% Continue if a tag `a` is not found in the references.
%
% \end{markdown}
@@ -28990,7 +29064,25 @@ function M.reader.new(writer, options)
% \end{macrocode}
% \begin{markdown}
%
-% Resolve a full link [a][b] from the delimiters at `opening_index` and `closing_index` within a delimiter table `t`.
+% Resolve a note `[^a]` from the delimiters at `opening_index` and `closing_index` within a delimiter table `t`.
+% Continue if a tag `a` is not found in the rawnotes.
+%
+% \end{markdown}
+% \begin{macrocode}
+ local function resolve_raw_note_link(t, opening_index, closing_index)
+ local content = collect_link_content(t, opening_index + 1, closing_index - 1)
+ local r = self.lookup_note_reference(content)
+
+ if r then
+ local parsed_ref = self.parser_functions.parse_blocks_nested(r)
+ render_link_or_image(t, opening_index, closing_index, closing_index, parsed_ref)
+ end
+ end
+
+% \end{macrocode}
+% \begin{markdown}
+%
+% Resolve a full link `[a][b]` from the delimiters at `opening_index` and `closing_index` within a delimiter table `t`.
% Continue if a tag `b` is not found in the references.
%
% \end{markdown}
@@ -29011,7 +29103,7 @@ function M.reader.new(writer, options)
% \end{macrocode}
% \begin{markdown}
%
-% Resolve a collapsed link [a][] from the delimiters at `opening_index` and `closing_index`
+% Resolve a collapsed link `[a][]` from the delimiters at `opening_index` and `closing_index`
% within a delimiter table `t`.
% Continue if a tag `a` is not found in the references.
%
@@ -29047,7 +29139,7 @@ function M.reader.new(writer, options)
for i,value in ipairs(t) do
if not value.is_closing or
value.type ~= "delimiter" or
- not (value.element == "link" or value.element == "image") then
+ not (value.element == "link" or value.element == "image" or value.element == "note") then
goto continue
end
@@ -29073,6 +29165,12 @@ function M.reader.new(writer, options)
if (link_type == "collapsed") then
resolve_collapsed_link(t, opener_position, i)
end
+ if (link_type == "note_inline") then
+ resolve_note_inline_link(t, opener_position, i)
+ end
+ if (link_type == "raw_note") then
+ resolve_raw_note_link(t, opener_position, i)
+ end
::continue::
end
@@ -31781,6 +31879,8 @@ M.extensions.notes = function(notes, inline_notes)
local parsers = self.parsers
local writer = self.writer
+ local rawnotes = parsers.rawnotes
+
if inline_notes then
local InlineNote
= parsers.circumflex
@@ -31799,8 +31899,6 @@ M.extensions.notes = function(notes, inline_notes)
= #(parsers.lbracket * parsers.circumflex)
* parsers.link_label / strip_first_char
- local rawnotes = {}
-
-- like indirect_link
local function lookup_note(ref)
return writer.defer_call(function()
@@ -35112,21 +35210,15 @@ end
\tl_set:Nn
\l_@@_latex_fancy_list_item_label_delimiter_style_tl
{ #2 }
- \tl_set:Nn
- \l_tmpa_tl
- {
- \plpartopsep=\partopsep
- \pltopsep=\topsep
- }
\@@_if_option:nTF
{ startNumber }
{
- \tl_put_right:Nn
+ \tl_set:Nn
\l_tmpa_tl
{ \begin{compactenum} }
}
{
- \tl_put_right:Nn
+ \tl_set:Nn
\l_tmpa_tl
{ \begin{compactenum}[ }
\tl_put_right:Nx
@@ -35136,6 +35228,12 @@ end
\l_tmpa_tl
{ ] }
}
+ \tl_put_left:Nn
+ \l_tmpa_tl
+ {
+ \plpartopsep=\partopsep
+ \pltopsep=\topsep
+ }
\tl_use:N
\l_tmpa_tl
},