Crates.io | atext2html |
lib.rs | atext2html |
version | 0.27.2 |
source | src |
created_at | 2020-12-28 21:51:59.083923 |
updated_at | 2023-10-19 16:28:49.26554 |
description | Convert a text with markup hyperlinks to HTML |
homepage | https://gitlab.com/getreu/parse-hyperlinks |
repository | https://gitlab.com/getreu/parse-hyperlinks |
max_upload_size | |
id | 328454 |
size | 34,262 |
Atext2html is a command line utility
written with Nom to recognize hyperlinks and
link reference definitions in Markdown, reStructuredText, Asciidoc, Wikitext and
HTML formatted text input. Atext2html
renders the source text verbatim to HTML while making hyperlinks clickable. By
default the hyperlink's text appears the same as in the source text. When the
flag --render-links
is given, hyperlinks are represented only by their link
text, which makes inline links more readable.
Atext2html illustrates the usage of the underlying library Parse-hyperlinks. The API of Parse-hyperlinks provides insights about the operating principle of this utility.
In addition to the above, Parse-hyperlinks-extras defines some extra parsers needed by the Tp-Note application.
cargo install atext2html
Render source text with markup hyperlinks.
USAGE:
atext2html [FLAGS] [OPTIONS] [FILE]...
FLAGS:
-h, --help Prints help information
-l, --only-links print only links (one per line)
-r, --render-links render hyperlinks
-V, --version print version and exit
OPTIONS:
-o, --output <output> print not to stdout but in file
ARGS:
<FILE>... paths to files to render (or `-` for stdin)
Create a file input.txt
with text and hyperlinks:
abc[text10](destination10 "title10")abc
abc[text11][label11]abc
abc[text12](destination2 "title12")
[text13]: destination3 "title13"
[label11]: destination1 "title11"
abc[text13]abc
Run atext2html
:
$ ./atext2html -o output.html input.txt
Inspect output.html
:
<pre>abc<a href="destination10" title="title10">[text10](destination10 "title10")</a>abc
abc<a href="destination1" title="title11">[text11][label11]</a>abc
abc<a href="destination2" title="title12">[text12](destination2 "title12")</a>
<a href="destination3" title="title13">[text13]: destination3 "title13"</a>
<a href="destination1" title="title11">[label11]: destination1 "title11"</a>
abc<a href="destination3" title="title13">[text13]</a>abc</pre>
This is how it looks like in the web browser:
$ firefox output.html
abc[text10](destination10 "title10")abc abc[text11][label11]abc abc[text12](destination2 "title12") [text13]: destination3 "title13" [label11]: destination1 "title11" abc[text13]abc
Create a file input.txt
with text and hyperlinks:
abc `text21 <label21_>`_abc
abc text22_ abc
abc text23__ abc
abc text_label24_ abc
abc text25__ abc
.. _label21: destination21
.. _text22: destination22
.. __: destination23
__ destination25
Run atext2html
:
$ ./atext2html -o output.html input.txt
Inspect output.html
:
<pre>abc <a href="destination21" title="">`text21 <label21_>`_</a>abc
abc <a href="destination22" title="">text22_</a> abc
abc <a href="destination23" title="">text23__</a> abc
abc text_label24_ abc
abc <a href="destination25" title="">text25__</a> abc
<a href="destination21" title=""> .. _label21: destination21</a>
<a href="destination22" title=""> .. _text22: destination22</a>
<a href="destination23" title=""> .. __: destination23</a>
<a href="destination25" title=""> __ destination25</a></pre>
This is how it looks like in the web browser:
$ firefox output.html
abc `text21 <label21_>`_abc abc text22_ abc abc text23__ abc abc text_label24_ abc abc text25__ abc .. _label21: destination21 .. _text22: destination22 .. __: destination23 __ destination25
Create a file input.txt
with text and hyperlinks:
abc
abc https://destination30[text30]abc
abc link:https://destination31[text31]abc
abc{label32}[text32]abc
abc{label33}abc
:label32: https://destination32
:label33: https://destination33
Run atext2html
:
$ ./atext2html -o output.html input.txt
Inspect output.html
:
<pre>abc
abc <a href="https://destination30" title="">https://destination30[text30]</a>abc
abc <a href="https://destination31" title="">link:https://destination31[text31]</a>abc
abc<a href="https://destination32" title="">{label32}[text32]</a>abc
abc<a href="https://destination33" title="">{label33}</a>abc
<a href="https://destination32" title="">:label32: https://destination32</a>
<a href="https://destination33" title="">:label33: https://destination33</a></pre>
This is how it looks like in the web-browser:
$ firefox output.html
abc abc https://destination30[text30]abc abc link:https://destination31[text31]abc abc{label32}[text32]abc abc{label33}abc :label32: https://destination32 :label33: https://destination33
Create a file input.txt
with text and hyperlinks:
abc
abc[https://destination31 text31]abc
Run atext2html
:
$ ./atext2html -o output.html input.txt
Inspect output.html
:
<pre>abc
abc<a href="https://destination31" title="">[https://destination31 text31]</a>abc
This is how it looks like in the web-browser:
$ firefox output.html
abc abc[https://destination31 text31]abc
Create a file input.txt
with text and hyperlinks:
abc<a href="dest1" title="title1">text1</a>abc
abc<a href="dest2" title="title2">text2</a>abc
Run atext2html
:
$ ./atext2html -o output.html input.txt
Inspect output.html
:
<pre>abc<a href="dest1" title="title1"><a href="dest1" title="title1">text1</a></a>abc
abc<a href="dest2" title="title2"><a href="dest2" title="title2">text2</a></a>abc</pre>
This is how it looks like in the web-browser:
$ firefox output.html
abc<a href="dest1" title="title1">text1</a>abc abc<a href="dest2" title="title2">text2</a>abc