This is a little script which converts a LyX file into an HTML file and "publishes" it on a local copy of your Jekyll-based blog. This script can be integrated in LyX.
LyXBlog supports:
\label{label_name{text_when_referenced}}
)<style>...</style>
in HTML{% highlight python %}
)LyXBlog [--update] [--args_from_file] <input file> <blog base dir> <assets relative dir>
where:
--update
is used when you want to update an article and it's OK to overwrite existing files--args_from_file
lets you drop the last two arguments (<blog base dir> <assets relative dir>
) and specify them in the front matter of the input fileinput file
is the LyX file to publishblog base dir
is the base dir of the local copy of your blog (e.g. c:\my_projects\blog
)assets relative dir
is the relative dir (e.g. assets
) of the directory where to put the imageslyx.exe
and pandoc.exe
must be in your search path and the script requires Python 3.
Every LyX file needs to contain a double front matter. The first part is a front matter for LyxBlog itself and the second one for Jekyll. The second front matter will be copied (almost) verbatim into the HTML file.
IMPORTANT: You need to insert (as TeX code (CTRL-L)) the double front matter between \begin{comment}
and \end{comment}
, right at the beginning of the file. You need the package verbatim
for the comment
environment.
Here's an example of double front matter:
\begin{comment}
---
html_file_name: distributional_rl # required
args:
blog_base_dir: D:\--- New Projects\mtomassoli.github.io
assets_rel_dir: assets
style: >
article { text-align: justify; }
article p { hyphens: auto; }
figure { margin-top: 1em; margin-bottom: 1em; }
figure figcaption { text-align: justify; text-align-last: center; margin: 0 5%; }
---
layout: post
title: Distributional RL
date: 2017-12-02
summary: An intuitive explanation of Distributional RL.
---
\end{comment}
html_file_name
is used by LyXBlog to name the HTML file (but the date will be added to the name as required by Jekyll). Use the basename of the file without any extension just like in the example above.args
is used to supply the last two arguments to LyXBlog when you're using --args_from_file
.style
is used to inject additional styling information to the final HTML file. I think the ones in the example above are good defaults.See distributional_rl.lyx
to see what you can do. The only missing feature is the use of labels in paragraphs. You just name the label using the format some_label_name{the part about distributions}
and then you reference to it with something like
As we saw in <ref-to-label>
This will give you something equivalent to
As we saw in [the part about distributions](link)
The script does the following:
article.lyx
to article.tex
with lyx.exe
article.tex
and look for:html_file_name
args
(blog_base_dir
, assets_rel_dir
)date
in Jekyll front matterarticle.tex
to article.html
with pandoc.exe
<blog base dir>\<assets relative dir>\<%date>-<%html_file_name>
article.html
style
attribute to article.html
_post*
with its proper name: <%date>-<%html_file_name>.html
verbatim
needed for the environment comment
by going to Document->Settings...->LaTeX Preamble
and adding the following:\usepackage{verbatim}
Document->Settings...->Language
and select Unicode (utf8)
under Encoding
.Go to Tools->Preferences...
and create the following two (fake) file formats:
Remember to click on New and Apply.
Then create the following two converters, one with and the other without --update
:
The field Converter
deserves an explanation:
python.exe
with the full path because LyX modifies its private search path to make it point to its copy of Python 2./
" for the Python path and "\
" for the other paths. This is a "portability issue", AFAICT.$$r$$i
is the full path of the LyX document.NOTE: If you want, you can drop the last two arguments and use --args_from_file
instead. This is especially useful if you have more blogs and want to select the destination blog directly in the LyX file.
Remember to click on Add, Apply and Save.
After you've done all that, you can run the script from File->Export
.
gem install bundler
<Your GitHub Username>.github.io
git clone https://github.com/<Your GitHub Username>/<Your GitHub Username>.github.io
bundle install
Now you can see your local blog by executing bundle exec jekyll serve
and by going to http://127.0.0.1:4000
.
_code.scss
:pre,
code {
font-family: $monospace-font-family;
font-size: 0.89rem;
}
figure.highlight {
margin-left: 0px;
margin-right: 0px;
}
.highlight .p { // for the parentheses!
font-size: 1.00125rem; /* 1.125 * "code.font-size" */
line-height: 1;
}