Using MathJax with Jekyll - jekyll

I have a Jekyll blog and I want to use MathJax with it, in the sense that I want to be able to type something like
$$\sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6}$$
in my markdown files, and have the correct LaTeX expression generated with MathJax, in a similar way to how it is done at math.stackexchange.
What is the easiest way to do this? Currently I have the file jsmath.js (GitHub gist) in my directory, and I thought I could have a simple file named mathjs in my _includes directory with the line
<script src="path/to/jsmath.js></script>
and include that in each post via
{% include mathjs %}
but this doesn't seem to work - when I run jekyll --server the page is generated, but none of the content is visible.
Am I going about this the right way? Is there a better way to use MathJax with Jekyll?

Certainly you can use mathjax with Jekyll. To get this working make sure that
If you're writing your post in markdown, your markdown interpreter isn't hammering your mathjax input. The best way to protect it I have found is to always put display math in <div> elements and inline math in <span> elements, which most markdown interpreters will leave alone.
Is the javascript line displaying correctly in the html source? I find it easier and faster to point to the mathjax CDN rather than provide my own copy. Try using the line
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
(Those configuration options allow you to use more tex notation to start your math environment, such as \begin{equation}, etc).
Perhaps there is some issue with your jsmath.js script; the CDN version will be faster and probably more reliable. (I have the javascript load in my footer on every page, but of course your strategy with include makes sense if you don't want to load the javascript when you don't need it.)
We could help more if you give us a link to your blog? You can see some examples on my blog (has link to Jekyll setup on github too if that helps).

If you have sufficient control over the publishing process (e.g. you are running Jekyll yourself), an easy solution is to switch the markdown parser to one that supports TeX. For example, using kramdown:
gem install kramdown
Change the markdown line in _config.yml to
markdown: kramdown
and add something like
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
to _layouts/default.html. Now you can simply mark any mathematics in your posts with $$.

If you are using kramdown as your markdown flavor, it's easy. Kramdown has built-in support for mathjax.
Add this before the </head> tag in your default layout.
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?
config=TeX-AMS-MML_HTMLorMML"></script>
Set this to true at _config.yml, after the markdown: kramdown line.
mathjax: true
Done. For renedering Mathjax
inline, use \( ... \),
block, use \[ ... \].
The only thing to look out for is the escaping of the backslash when using markdown, so the delimiters become \\( ... \\) and \\[ ... \\] for inline and block maths respectively.
Here is an example of MathJax inline rendering \\( 1/x^{2} \\), and here is a block rendering:
\\[ \frac{1}{n^{2}} \\].
I use this on my blog.

I wrote a blog post about setting up MathJax a while back: Latex Math Magic
In essence you have to stop the Markdown from messing with the MathJax.
I ended up using code blocks, which worked fine for me. So either using at least 4 spaces before you write something or using the acute symbol: `;
Unfortunately MathJax is skipping <code> tags by default since it doesn’t want to convert code that it shouldn’t.
So somewhere in your main layout file you have to add a little javascript code:
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
});
Additionally we have to tell MathJax to ignore non-latex code-blocks or normal code blocks:
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
At his point all our latex code blocks are going to have the has-jax string in their class name. Therefore we can apply some simple styling in our css sheets to give it our own styling.
code.has-jax {font: inherit; font-size: 100%; background: inherit; border: inherit;}
Might not be the best approach but it worked for my blog for the past years and I never encountered any further problem with it.

You may try my static blog generator: Jekyde. Jekyde is similar to Jekyll, but it takes care of LaTeX in Markdown file well. You only need to put your formulas inside $...$ and $$...$$. Also Jekyde contains a markdown editor in browser with LaTeX preview.

Jekyll uses kramdown as a default markdown converter from 2.0+. And It doesn't support the mathjax and so on, I think the below can help you.
jekyll-spaceship - 🚀 A Jekyll plugin to provide powerful supports for
table, mathjax, plantuml, youtube, vimeo, dailymotion, etc.
https://github.com/jeffreytse/jekyll-spaceship
Put your math expression within $...$
$\LaTeX{}$
$\Pi$
$ a * b = c ^ b $
$ 2^{\frac{n-1}{3}} $
$ \int\_a^b f(x)\,dx. $
Code above would be parsed as:

Some notes before trying either of the following options
Option 0 will increase build times even with --incremental and really option 1 should likely be used in most instances, however, this along with the extra space taken up maybe worth the costs if you're deploying on a network with clients that may not have access to CDNs.
Both options have been tested on a private server with kramdown as the markdown interpreter and mathjax: true set within the project's _config.yml file; see Step 2 of Soham Bhattacharyya's answer and their preface, and upto Caramdir's first two code blocks for the how-to for those bits.
Option 0 download and copy the unpacked source to project-name
Download the source
cd ~
mkdir -p git/hub && cd git/hub
git clone --depth 1 https://github.com/mathjax/MathJax.git
Make a directory path in your project's and copy files from MathJax/unpacked to this path
cd ~
mkdir -p git/lan/project-name/assets/JS_3rd_Party/MathJax
cp -r git/hub/MathJax/unpacked/* git/lan/project-name/assets/JS_3rd_Party/MathJax/
Add the source to git tracking
cd git/lan/project-name/
git add assets/JS_3rd_Party/MathJax
git commit -m 'Added MathJax.js unpacked source to git tracking'
Write an include file
tee ./_includes/MathJax.html 1>/dev/null <<EOF
{%- if jekyll.environment == 'production' and site.mathjax == true -%}
<script type="text/javascript" src="{{'/assets/javascripts/JS_3rd_Party/latest.js?config=TeX-AMS-MML_HTMLorMML' | relative_url}}"></script>
{%- elsif jekyll.environment != 'production' and site.mathjax == true -%}
<script type="text/javascript" src="{{'/assets/javascripts/JS_3rd_Party/MathJax.js?config=TeX-AMS-MML_HTMLorMML' | relative_url}}"></script>
{%- endif -%}
EOF
Private server builds will use MathJax.js where as production environment (GitHub) will use latest.js using the above Liquid if...elsif...endif statement.
Write a post to test it
tee ./_posts/$(date +'%Y-%d-%m')-math-tests.markdown 1>/dev/null <<EOF
---
layout: post
title: "Math Tests"
date: $(date +'%Y-%d-%m %H:%M:%S %z')
categories: math
---
{%- include MathJax.html -%}
<span>
for $x,y,z \in \{1, 2,\dots 9\}$
</span>
<span>
$$
\sum_{i=1}^n X_n
$$
</span>
EOF
I've not tried it without <span>s because cboettig's suggestion seems to totally do the trick.
Additionally that extra new-line within spans are no mistake, without'em there where still issues with rendered output.
Add these latest files to git tracking
git add _posts/$(date +'%Y-%d-')math-tests.markdown
git add _includes/MathJax.html
Build locally, or push and build on a remote server
bundle exec jekyll build --destination /tmp/www/project-name --config _config.yml --incremental
Option 1 copy just latest.js to use a CDN (Content Delivery Network)
See Option 0 step 1.
Make a directory path for third party JavaScripts and copy MathJax/unpacked/latest.js there
cd ~
mkdir -p git/lan/project-name/assets/JS_3rd_Party/MathJax
cp git/hub/MathJax/unpacked/latest.js git/lan/project-name/assets/JS_3rd_Party/MathJax/
Write an include file
cd git/lan/project-name
tee ./_includes/MathJax.html 1>/dev/null <<EOF
<script type="text/javascript" src="{{'/assets/javascripts/JS_3rd_Party/latest.js?config=TeX-AMS-MML_HTMLorMML' | relative_url}}"></script>
EOF
See Option 0 Step 5.
Add these three files to git tracking
git add _includes/MathJax.html
git add _posts/$(date +'%Y-%d-')math-tests.markdown
git add assets/JS_3rd_Party/MathJax
git commit -m 'Added `MathJax.html`, `latest.js`, and a test post to git tracking'
See Option 0 Step 7. for building locally
For either of the options
If deploying on a private server you may also need to define baseurl within your project's _config.yml file, especially if emulating the username.tld/project-name URL scheme that GitHub uses on your private server.
If deploying to both a private server and GitHub it may be better to use a separate config file and when building issue --config _config.yml,_config_baseurl.yml, eg...
# Write the special config file
tee ./_config_baseurl.yml 1>/dev/null <<EOF
baseurl: "project-name"
EOF
# Build with extra config
bundle exec jekyll build --destination /tmp/www/project-name --config _config.yml,_config_baseurl.yml --incremental
Hope that helps with loading assets via an include.

For me adding this to my default _layout or head _include works (in combination with a front matter _page or _post variable):
---
mathjax: yes
---
<!-- mathjax -->
{% if page.mathjax %}
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/MathJax.js?config=TeX-MML-AM_CHTML">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [["$", "$"], ["\\(", "\\)"]],
processEscapes: true
}
});
</script>
{% endif %}
working example

For those using the Jekyll Chirpy, you simply need to add math : true to the front matter of your post.
For website performance reasons, the mathematical feature won’t be loaded by default.
Source
At the time of this post, Jekyll Chirpy uses MathJax 3.2.

Related

Showing LAtex formulas in GitHub markdown.md [duplicate]

Is there any way to render LaTex in README.md in a GitHub repository? I've googled it and searched on stack overflow but none of the related answers seems feasible.
For short expresions and not so fancy math you could use the inline HTML to get your latex rendered math on codecogs and then embed the resulting image. Here an example:
- <img src="https://latex.codecogs.com/gif.latex?O_t=\text { Onset event at time bin } t " />
- <img src="https://latex.codecogs.com/gif.latex?s=\text { sensor reading } " />
- <img src="https://latex.codecogs.com/gif.latex?P(s | O_t )=\text { Probability of a sensor reading value when sleep onset is observed at a time bin } t " />
Which should result in something like the next
Update: This works great in eclipse but not in github unfortunately. The only work around is the next:
Take your latex equation and go to http://www.codecogs.com/latex/eqneditor.php, at the bottom of the area where your equation appears displayed there is a tiny dropdown menu, pick URL encoded and then paste that in your github markdown in the next way:
![equation](http://latex.codecogs.com/gif.latex?O_t%3D%5Ctext%20%7B%20Onset%20event%20at%20time%20bin%20%7D%20t)
![equation](http://latex.codecogs.com/gif.latex?s%3D%5Ctext%20%7B%20sensor%20reading%20%7D)
![equation](http://latex.codecogs.com/gif.latex?P%28s%20%7C%20O_t%20%29%3D%5Ctext%20%7B%20Probability%20of%20a%20sensor%20reading%20value%20when%20sleep%20onset%20is%20observed%20at%20a%20time%20bin%20%7D%20t)
I upload repositories with equations to Gitlab because it has native support for LaTeX in .md files:
```math
SE = \frac{\sigma}{\sqrt{n}}
```
The syntax for inline latex is $`\sqrt{2}`$.
Gitlab renders equations with JavaScript in the browser instead of showing images, which improves the quality of equations.
More info here.
Let's hope Github will implement this as well in the future.
My trick is to use the Jupyter Notebook.
GitHub has built-in support for rendering .ipynb files. You can write inline and display LaTeX code in the notebook and GitHub will render it for you.
Here's a sample notebook file: https://gist.github.com/cyhsutw/d5983d166fb70ff651f027b2aa56ee4e
Readme2Tex
I've been working on a script that automates most of the cruft out of getting LaTeX typeset nicely into Github-flavored markdown: https://github.com/leegao/readme2tex
There are a few challenges with rendering LaTeX for Github. First, Github-flavored markdown strips most tags and most attributes. This means no Javascript based libraries (like Mathjax) nor any CSS styling.
The natural solution then seems to be to embed images of precompiled equations. However, you'll soon realize that LaTeX does more than just turning dollar-sign enclosed formulas into images.
Simply embedding images from online compilers gives this really unnatural look to your document. In fact, I would argue that it's even more readable in your everyday x^2 mathematical slang than jumpy .
I believe that making sure that your documents are typeset in a natural and readable way is important. This is why I wrote a script that, beyond compiling formulas into images, also ensures that the resulting image is properly fitted and aligned to the rest of the text.
For example, here is an excerpt from a .md file regarding some enumerative properties of regular expressions typeset using readme2tex:
As you might expect, the set of equations at the top is specified by just starting the corresponding align* environment
**Theorem**: The translation $[\![e]\!]$ given by
\begin{align*}
...
\end{align*}
...
Notice that while inline equations ($...$) run with the text, display equations (those that are delimited by \begin{ENV}...\end{ENV} or $$...$$) are centered. This makes it easy for people who are already accustomed to LaTeX to keep being productive.
If this sounds like something that could help, make sure to check it out. https://github.com/leegao/readme2tex
Since May 2022, this has been officially supported:
Inline:
Where $x = 0$, evaluate $x + 1$
Blocks:
Where
$$x = 0$$
Evaluate
$$x + 1$$
One can also use this online editor: https://www.codecogs.com/latex/eqneditor.php which generates SVG files on the fly. You can put a link in your document like this:
![](https://latex.codecogs.com/svg.latex?y%3Dx%5E2) which results in:
.
I test some solution proposed by others and I would like to recommend TeXify created and proposed in comment by agurodriguez and further described by Tom Hale - I would like develop his answer and give some reason why this is very good solution:
TeXify is wrapper of Readme2Tex (mention in Lee answer). To use Readme2Tex you must install a lot of software in your local machine (python, latex, ...) - but TeXify is github plugin so you don't need to install anything in your local machine - you only need to online installation that plugin in you github account by pressing one button and choose repositories for which TeXify will have read/write access to parse your tex formulas and generate pictures.
When in your repository you create or update *.tex.md file, the TeXify will detect changes and generate *.md file where latex formulas will be exchanged by its pictures saved in tex directory in your repo. So if you create README.tex.md file then TeXify will generate README.md with pictures instead tex formulas. So parsing tex formulas and generate documentation is done automagically on each commit&push :)
Because all your formulas are changed into pictures in tex directory and README.md file use links to that pictures, you can even uninstall TeXify and all your old documentation will still works :). The tex directory and *.tex.md files will stay on repository so you have access to your original latex formulas and pictures (you can also safely store in tex directory your other documentation pictures "made by hand" - TeXify will not touch them).
You can use equations latex syntax directly in README.tex.md file (without loosing .md markdown syntax) which is very handy. Julii in his answer proposed to use special links (with formulas) to external service e.g . http://latex.codecogs.com/gif.latex?s%3D%5Ctext%20%7B%20sensor%20reading%20%7D which is good however has some drawbacks: the formulas in links are not easy (handy) to read and update, and if there will be some problem with that third-party service your old documentation will stop work... In TeXify your old documentation will works always even if you uninstall that plugin (because all your pictures generated from latex formulas are stay in repo in tex directory).
The Yuchao Jiang in his answer, proposed to use Jupyter Notebook which is also nice however have som drawbacks: you cannot use formulas directly in README.md file, you need to make link there to other file *.ipynb in your repo which contains latex (MathJax) formulas. The file *.ipynb format is JSON which is not handy to maintain (e.g. Gist don't show detailed error with line number in *.ipynb file when you forgot to put comma in proper place...).
Here is link to some of my repo where I use TeXify for which documentation was generated from README.tex.md file.
Update
Today 2020.12.13 I realised that TeXify plugin stop working - even after reinstallation :(
For automatic conversion upon push to GitHub, take a look at the TeXify app:
GitHub App that looks in your pushes for files with extension *.tex.md and renders it's TeX expressions as SVG images
How it works (from the source repository):
Whenever you push TeXify will run and seach for *.tex.md files in your last commit. For each one of those it'll run readme2tex which will take LaTeX expressions enclosed between dollar signs, convert it to plain SVG images, and then save the output into a .md extension file (That means that a file named README.tex.md will be processed and the output will be saved as README.md). After that, the output file and the new SVG images are then commited and pushed back to your repo.
I just published a new version of xhub, a browser extension that renders LaTeX (and other things) in GitHub pages.
Cons:
You have to install the extension once.
Pros:
No need to set up anything.
Just write Markdown with math
Display math:
```math
e^{i\pi} + 1 = 0
```
and line math $`a^2 + b^2 = c^2`$.
(Syntax like on GitLab.)
Works on light and dark background. (Math has text-color)
You can copy-and-paste the math just like text
As an example, check out this GitHub README:
You can get a continuous integration service (e.g. Travis CI) to render LaTeX and commit results to github. CI will deploy a "cloud" worker after each new commit. The worker compiles your document into pdf and either cuses ImageMagick to convert it to an image or uses PanDoc to attempt LaTeX->HTML conversion where success may vary depending on your document. Worker then commits image or html to your repository from where it can be shown in your readme.
Sample TravisCi config that builds a PDF, converts it to a PNG and commits it to a static location in your repo is pasted below. You would need to add a line that fetches pdfconverts PDF to an image
sudo: required
dist: trusty
os: linux
language: generic
services: docker
env:
global:
- GIT_NAME: Travis CI
- GIT_EMAIL: builds#travis-ci.org
- TRAVIS_REPO_SLUG: your-github-username/your-repo
- GIT_BRANCH: master
# I recommend storing your GitHub Access token as a secret key in a Travis CI environment variable, for example $GH_TOKEN.
- secure: ${GH_TOKEN}
script:
- wget https://raw.githubusercontent.com/blang/latex-docker/master/latexdockercmd.sh
- chmod +x latexdockercmd.sh
- "./latexdockercmd.sh latexmk -cd -f -interaction=batchmode -pdf yourdocument.tex -outdir=$TRAVIS_BUILD_DIR/"
- cd $TRAVIS_BUILD_DIR
- convert -density 300 -quality 90 yourdocument.pdf yourdocument.png
- git checkout --orphan $TRAVIS_BRANCH-pdf
- git rm -rf .
- git add -f yourdoc*.png
- git -c user.name='travis' -c user.email='travis' commit -m "updated PDF"
# note we are again using GitHub access key stored in the CI environment variable
- git push -q -f https://your-github-username:$GH_TOKEN#github.com/$TRAVIS_REPO_SLUG $TRAVIS_BRANCH-pdf
notifications:
email: false
This Travis Ci configuration launches a Ubuntu worker downloads a latex docker image, compiles your document to pdf and commits it to a branch called branchanme-pdf.
For more examples see this github repo and its accompanying sx discussion, PanDoc example,
https://dfm.io/posts/travis-latex/, and this post on Medium.
I have been looking around and found that this answer in another question works best for me. i.e. use githubcontent math renderer, e.g. to display:
Use this link
Beware of the latex needs to be url encoded, but otherwise work quite well for me.
If you are having issues with https://www.codecogs.com/latex/eqneditor.php, I found that https://alexanderrodin.com/github-latex-markdown/ worked for me. It generates the Markdown code you need, so you just cut and paste it into your README.md document.
You may also take a look on my tool latexMarkdown2Markdown which convert LaTeX to SVG and generate a table of content with chapter numbering.
Good news!
According to this blogpost, now GitHub supports Mathjax in readme files.
You can use in-line LaTeX inspired syntax using $ delimiters, or in-blocks using $$ delimiters.
Writing inline expressions:
This sentence uses $ delimiters to show math inline:
$\sqrt{3x-1}+(1+x)^2$
Writing expressions as blocks:
The Cauchy-Schwarz Inequality
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2
\right) \left( \sum_{k=1}^n b_k^2 \right)$$
Source: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions
You can use markdowns, e.g.
![equ](https://latex.codecogs.com/gif.latex?log(y)=\beta_0&space;&plus;&space;\beta_1&space;x&space;&plus;&space;u)
Code can be typed here: https://www.codecogs.com/latex/eqneditor.php.
Edit: As germanium pointed out, it does not work for README.md but other git pages though no explanation is available.
My quick solution is this
step 1. Add latex to your .md file
$$x=\sqrt{2}$$
Note: math eqns must be in $$...$$ or \\(... \\).
step 2. Add the following to your scripts.html or theme file (append this code at the end)
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
Done!. See your eq. by loading the page.

Why is salt['slsutil.banner'] returning None whatever arguments I pass?

I'm using saltstack to manage my personal config. In particular I'm managing my ~/.profile programatically. I have various things throughout the setup which append text (mostly env var exports) to it, and they all work exactly as expected. I want to to use slsutil.banner to prepend a banner saying that the file is managed programatically by salt, and not to touch it by hand. So I have in my profile/init.sls:
profile-managed-banner:
file.prepend:
- name: {{ pillar['profile_file'] }}
- text: {{ salt['slsutil.banner']() }}
This should write the default banner to the beginning of the file.
When I then run run salt-call (the setup is masterless. Running salt-call as sudo if that's at all relevant) I get:
ID: profile-managed-banner
Function: file.prepend
Name: /home/modallyFragile/.saltProfile
Result: True
Comment: File /home/modallyFragile/.saltProfile is in correct state
Started: 15:59:07.760790
Duration: 1.757 ms
Changes:
So clearly salt can find and use all the functions (or at least it thinks it can) and the the file is having something prepended to it. If I check the file though, I get this:
None
[ ... further config here]
If I substitute the templating for a string (so - text: some string here) it works as expected (prepends 'some string' to the file). So the probelm is with the templating slsutil.banner then. I've tried passing (various combinations of) arguments explicitly and nothing seems to help.
Why might this be happening and what can I do about it? Failing anything more substantive, what could I do to further diagnose the problem (I'm pretty new to saltstack, is there a particular log I should be checking with all the relevant info, etc. etc.)?
I can't find any issues or problems by searching (github or more generally), so I'm drawing a blank. Literally any suggestions would be really helpful. Thanks!
Adding this as an answer. As per the official documentation:
Create a standardized comment block to include in a templated file.
And this does work inside a templated file.
Just for example files/user-profile.j2:
{{ salt.slsutil.banner() }}
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
umask 022
PATH=$PATH:/my/local/bin
Used in a setup.sls:
create-user-profile:
file.managed:
- name: /home/user1/.profile
- source: salt://files/user-profile.j2
- template: jinja
Will create a file /home/user1/.profile with a default banner at the top and the remaining content as it is.
Then it starts making sense. If you want a banner on file that "it is managed by Salt", then the file should be managed by Salt (as template). Prepending the banner in a remote file, leaving the remaining file contents unmanaged contradicts the purpose of the banner.
So if you want a banner in the file, you can manage the ~/.profile file as a template, and write it to minions as above.
Update:
It might be worth reporting this as an issue if we want a custom banner prepended to a file without managing it.
The problem is that your Jinja, once rendered, produces invalid or incorrect YAML. In this case, what is happening is that the slsutil.banner() function returns several lines that all start with '#'. The YAML renderer considers them comments and throws them out.
The solution is to escape the comment characters so they are properly interpreted by the YAML renderer. Fortunately, Salt comes with a very helpful Jinja filter that does this for you: yaml_encode. Your state works fine with this small change.
profile-managed-banner:
file.prepend:
- name: {{ pillar['profile_file'] }}
- text: {{ salt['slsutil.banner']() | yaml_encode }}

git commits into html filr through jenkins

I am passing a HTML file through Jenkins from build to production servers.
I am injecting the build number into the HTML file using perl.
Now I also want to inject the git commits into the HTML page.
The below is how I injected build number in place of the {BUILD_VERSION} in the HTML page.
perl -pi -e 's/{BUILD_VERSION}/Android_IT_ACCEPTANCE - $ENV{build}/g' index.html
Now, I want git commits in release notes page. I tried this. It didn't workout.
perl -pi -e 's/{RELEASE_NOTES}/Release Notes: $ENV{Change}/g' index.html
I may be misunderstanding you, because it's unclear how you came up with build in the environment, but looking at the Jenkins environment variable docs it kind of looks like you want to be using these:
BUILD_NUMBER The current build number, such as "153"
BUILD_ID The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss, defunct since version 1.597)
BUILD_URL The URL where the results of this build can be found (e.g. http://buildserver/jenkins/job/MyJobName/666/)
...
GIT_COMMIT For Git-based projects, this variable contains the Git hash of the commit checked out for the build (like ce9a3c1404e8c91be604088670e93434c4253f03) (all the GIT_* variables require git plugin)
GIT_URL For Git-based projects, this variable contains the Git url (like git#github.com:user/repo.git or [https://github.com/user/repo.git])
GIT_BRANCH For Git-based projects, this variable contains the Git branch that was checked out for the build (normally origin/master)
So maybe you're looking for something more like:
perl -pi -e '
s/{BUILD_VERSION}/Android_IT_ACCEPTANCE - $ENV{BUILD_NUMBER}/g;
s/{RELEASE_NOTES}/Release Notes: $ENV{GIT_COMMIT}/g;
' index.html

Best practices to bundle Polymer components

Polymer dist/ folder has a single html file https://github.com/Polymer/polymer/tree/master/dist with a HTML import and a script tag. Most of the polymer elements doesn't even have a dist folder. Wouldn't it be a good practice to provide a single distribution bundle file like polymer.js and do the same for each polymer element available there?
There are some obvious advantages with this approach:
1. Minimum http requests to get the polymer core or a polymer element.
2. Easy to use for the clients, just include the required element.
Example: Elements that depend on other shared elements,
- shared-element: /webcomponents/font-roboto/roboto.js
- custom-element1: uses shared-element
- custom-element2: uses shared-element
An app using custom-element1 and custom-element2 downloads /webcomponents/font-roboto/roboto.js
only once with a single http request.
<script src="../webcomponents/webcomponentsjs/webcomponents.js"></script>
<script src="../webcomponents/custom-element1/custom-element1.js"></script>
<script src="../webcomponents/custom-element2/custom-element2.js"></script>
PS: the above custom-element1.js does the same thing as custom-element1.html expect that it is convenient to programmatically load and access the component.
I would like to hear from polymer team or other polymer developers/users on the best practices they are following to solve this.
If I'm understanding you correctly, what you want is Vulcanize.
As of the time of this writing, for polymer 1.0, the instructions are:
If you have an input HTML file, elements.html, that uses a number of HTML imports, you can run it through Vulcanize as follows:
vulcanize elements.html -o elements.vulcanized.html
The -o or --output flag will direct the output to a new file called elements.vulcanized.html. If you omit the -o flag, Vulcanize will print the output to stdout, which can be useful if you want to pipe it to another command.
elements.vulcanized.html now contains a version of elements.html with all imports inlined and dependencies flattened. Paths to any URLs are automatically adjusted for the new output location, with the exception of those set in JavaScript.
You can pass additional options to Vulcanize in the form of flags. For a full list of supported flags, see the official Vulcanize documentation.
Here’s the same example from above. The extra flags tell Vulcanize to strip out comments, and to merge external scripts and CSS files into the vulcanized file.
vulcanize -o elements.vulcanized.html elements.html --strip-comments --inline-scripts --inline-css
https://www.polymer-project.org/1.0/tools/optimize-for-production.html

Doxygen RTF disable Index (at end of document)?

Using doxygen 1.8.4 on Ubuntu 12.04
Generating for C/C++ source into an RTF file.
I'd like to disable the generation of the Index at the end of the document.
There are many hits for DISABLE_INDEX but this is the index at the top of HTML pages, not the main index at the end of the file. I've also searched the documentation for configuration for "index" and none of the hits seem to be about that particular index.
Update: This is also set to NO:
ALPHABETICAL_INDEX = NO
I looked in the DoxygenLayout file and there doesn't seem to be anything specific about the Index section. There are sub-indexes for namespaces, classes, and files. But nothing that I can see for the Index section. I'm not even sure if the DoxygenLayout file is used for RTF files, because of this comment:
<!-- Navigation index tabs for HTML output -->
Any help or pointers will be greatly appreciated!
TIA
John
Well this isn't an answer for this exact post. But it does indicate how to disable the generation of indexes and table of contents for Latex/PDFs.
set GENERATE_LATEX=YES and MAKEINDEX_CMD_NAME = echo
run doxygen to generate the latex file refman.tex
cd into the output directory named in LATEX_OUTPUT (typically "latex")
copy the Makefile to another directory and edit it:
remove all calls to "pdflatex refman" except the first
remove the loop
remove all calls to "echo refnam.idx"
It will look something like:
all: refman.pdf
pdf: refman.pdf
refman.pdf: clean refman.tex
pdflatex refman
clean:
rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf
cd into the output directory again and invoke the modified Makefile
cd latex
make -f ../../doc/Makefile
take a look at refman.pdf. The Table of Contents is gone, the Index is gone.
Caveat: So this works in latex output but does not work for RTF.
For my project, I've converted back to using latex, and so is a solution for me...