-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File transclusion #4
Comments
I am quite fond of the idea to replace the Markdown image tag with something more seamless. It is a simple matter to add experimental support for converting /Savings Account.csv 'Recent Transactions'
/Example.swift
/Lorem Ipsum.txt
http://example.com/minard.jpg (Napoleon’s disastrous Russian campaign of 1812)
/Flowchart.png "Enginering Flowchart" into \markdownRendererContentBlockLocal{Savings Account.csv}{Recent Transactions}
\markdownRendererContentBlockLocal{Example.swift}{}
\markdownRendererContentBlockLocal{Lorem Ipsum.txt}{}
\markdownRendererContentBlockOnline{http://example.com/minard.jpg}{Napoleon’s disastrous Russian campaign of 1812}
\markdownRendererContentBlockLocal{Flowchart.png}{Enginering Flowchart} but the real question is how much pre-processing should be done by |
I think that So, the result could be something like:
Regarding tables, I think that Online referenced can be only images. I am not sure whether it's possible to download content from the internet from engines other than LuaTeX, so it it probably should be downloaded by |
It might me a good idea to load all the
True, but it might still make more sense to parse the CSV and produce table renderer macros specific to the
We will need to produce the cache filenames by hashing the URLs, since that is the only information we have at disposal while offline. |
I appologize for the wait; I did not have the time to work on the feature until now. The feature-file-transclusion branch should contain all the necessary code. With the With the
An example LaTeX document: \documentclass{article}
\begin{filecontents*}{scientists.md}
Foo bar
\end{filecontents*}
\begin{filecontents*}{scientists.csv}
name,surname,age
Albert,Einstein,133
Marie,Curie,145
Thomas,Edison,165
\end{filecontents*}
\usepackage[contentBlocks,contentBlockPolymorphism]{markdown}
\begin{document}
\begin{markdown}
/scientists.md
/scientists.csv
\end{markdown}
\end{document} (UPDATE: Note that the current version renders the table as a float instead.) I considered doing URL fetching, but decided against it in the end, as it seems difficult to provide an implementation that would be both simple and robust. The users may implement URL fetching themselves: \documentclass{article}
\usepackage[contentBlocks,contentBlockPolymorphism]{markdown}
\usepackage{graphicx}
\begingroup
\catcode`\@=11
\catcode`\%=12
\catcode`\^^A=14
\global\def\markdownRendererImage#1#2#3#4{^^A
\immediate\write18{^^A
if printf '%s' "#3" | grep -q ^http; then
OUTPUT="$(printf '%s' "#3" | md5sum | cut -d' ' -f1).^^A
$(printf '%s' "#3" | sed 's/.*[.]//')";
if ! [ -e "$OUTPUT" ]; then
wget -O- '#3' > "$OUTPUT";
fi;
printf '%s%%' "$OUTPUT" > \jobname.fetched;
else
printf '%s%%' "#3" > \jobname.fetched;
fi}^^A
{\everyeof={\noexpand}^^A
\edef\filename{\@@input"\jobname.fetched" }^^A
\includegraphics[width=\textwidth]{\filename}}}
\endgroup
\begin{document}
\begin{markdown}
https://cloud.githubusercontent.com/assets/603082/24072692/17f79436-0beb-11e7-8da9-6bfbd6e1ec7d.png
![Martin Scharrer's example image](example-image)
\end{markdown}
\end{document} If some package provided a I will merge and release by the next weekend. In the meantime, I will be grateful for any feedback; especially regarding the compatibility with the iA Writer. I don't own any Apple devices and the Android OS version of the editor does not seem to implement file transclusion, so my opportunities for testing are limited. |
That's great, thanks! I think that the URL fetching isn't so important, it wouldn't be easy to implement it in a portable way. I've tried Markdown, CSV, image and code inclusion and it works perfectly. The only issue I found was that
in the document preamble. |
Note that all Currently the Last thing on my mind: the
and let the user decide whether they want to delegate the |
Also the |
It also seems that many languages are missing from the Anyway, it seems like a good idea to use different JSON files for each particular syntax highlighter, as they may use different names for one language. |
Recently released iA Writer has interesting extension to Markdown, they call it content blocks. This enables easy inclusion of images, tables, source code and child documents. For example:
would create the table from file
Savings Account.csv
, includeExample.swift
as source code and include contents ofLorem Ipsum.txt
processed with Markdown.More details can be found in this post, there is also in depth description.
I guess that it wouldn't be easy to support for example the syntax highlighting and CSV inclusion in all TeX engines, but I like the idea. What do you think?
The text was updated successfully, but these errors were encountered: