I am using GitHub pages to write my blog, and an article about regex (regular expression) owns markdown code like this:
---
layout: post
---
inline code blocks: pls replace `(\[(?:[^\]])(.)` by `$1~$2`
However, the resulting page is
(compiling result of the above markdown)
I am new to Jekyll, so can anyone tells me what happens and how to avoid it? Here are my guesses:
Jekyll thinks that there is an equation in (\[(?:[^\]])(.).
all is ok if the two inline code blocks were code blocks, but I think that it is too ugly.
My theme is
gem "minima", "~> 2.5"
Thanks for #Benjamin W. for his direction.
In the document there is an option skipTags that tells mathjax which code are needed to be skipped.
Add code to it solves the problem.
Related
My github jekyll structure looks like next:
after I enter _posts and create .md file, it looks like:
the corresponding code is:
Generics were introduced to the Java language to provide tighter type checks at compile time and to support generic programming.
The generics looks like:
```Java
List<String> list = new ArrayList<>();
//add item to list
String s = list.get(0);
```
or
```Java
public class Box<T> {
// T stands for "Type"
private T t;
//other code
}
```
The most commonly used type parameter names are:
```
E - Element (used extensively by the Java Collections Framework)
K - Key
```
We can see that the format is nice, such as it has syntax highlight.
I called it preview page
However, when I enter into my page by typing my github page url to see, it likes:
I called it real page
We can see that real page looks bad, e.g. there is no syntax highlight, there are multiple borders for quoting code syntax etc.
Thus, how to make the real page format is the same as preview page?
I suppose that you're relatively new to Jekyll so I have to do some clarification to you.
The result that you call "preview" is the result of your markdown parsed by GitHub. All markdowns have something in common so it's very likely that even if your parser is different almost all the things are parsed similarly. You could see a difference at the beginning of your "preview": the yaml content is displayed as a table.
Let's come back to Jekyll. If you're using the default settings, the parser of your code is kramdown (you could change it in the _config.yml file). When you execute Jekyll, it builds your website. That means that it parses your markdown and convert it to HTML. How it converts to HTML depends on a lot of things based on your configuration and plugin installed.
By default, you have no highlight. If you want to change it, take a look at the jekyll documentation. By default, it uses Rogue but you can also use Pigments or some other highlighter of your choice.
I don't think that this answer covers all your doubts and certainly not all your problems but it's to let you understand that your question, as it was posted, have not so much sense since your "preview page" and your "real page" are two completely distinct things. So google a bit, find what you want to achieve and ask a new question (you will surely have one in the near future).
Happy coding!
I would like to do something like this:
```swift
let someVar = "foo"
```
in Jekyll, and have it show up as a highlighted block of Swift code, where someVar can be clicked and go to #. Currently the tag is printed and visible instead. I know it's not exactly what the syntax highlighting feature in Jekyll is for, but is it possible in any way to add links to highlighted code blocks, without manually highlighting myself? Is there perhaps some other GitHub Pages-compatible plugin that could do this?
Looking at the code, there doesn't seem to be any way to escape code formatting inside a Jekyll Rouge highlight Liquid block to either to go back out to markdown parsing, or to insert raw HTML.
Another approach would be to use JavaScript to parse the content of your HTML and substitute in a link whenever you see the corresponding tag.
More info: Replace words in the body text
This question of how to include text that will appear in html but not pdf has been answered twice (LaTeX multicolumn block in Pandoc markdown and Pandoc markdown: Omit text in PDF version but include in HTML version) and I applied the solution recommended:
Here is the source:
My text.
<div>
This will be ignored in non-HTML output
</div>
Other text
The command I used was:
pandoc essai.md --from=markdown-markdown_in_html_blocks -o essai.pdf
Yet the text between the <div>tags is still displayed in the pdf file.
Am I missing something obvious? Or has the behaviour of pandoc changed since 2013/2014 (my version is 1.19 of 2016)? If yes, what would the solution be?
I know you asked for a solution that works with pandoc 1.19, but for completeness, here is one which is a bit cleaner but only works with pandoc 2.0 and later:
There is a new raw_attribute extension, which allows to do the following:
`text in html`{=html}
`text in pdf`{=latex}
It is enabled in pandoc markdown per default.
I found an answer: add the -native_divs extension.
This way:
$ pandoc essai.md --from=markdown-markdown_in_html_blocks-native_divs -t latex
My text.
other text
My understanding is that pandoc has started interpreting <div> items as "native" elements, i.e. represented in the AST, which causes the interesting side effect that a <p> is added in html. This behaviour needs to be deactivated in order to obtain the desired effect.
If someone has a better solution or a better explanation, please let me know.
On my way to becoming a datajournalist, I have come across lots of fantastic tools, such as R and Rmarkdown. Now that I work for a proper newspaper, I realize that most of the time, I end up using MS Excel (which, I don't deny, is also a great tool) and a concatenate function that I paste in an HTML file. I am losing quite a lot of my R knowledge and practice, and that's sad.
I know that I will soon be faced with a task that I would like to use as a way to get back to R and Rmarkdown.
I have some html pages working just fine and I'd like to change the data that is presented in them using Rmd.
My question is : is there a package or a way to combine into one Rmarkdown file most of an HTML page (header, css and javascript files and analytics, footer), and some Rmarkdown chunks ?
Thanks a lot for your answer.
Maybe you could try something like this (http://rmarkdown.rstudio.com/html_document_format.html#includes):
---
title: "Habits"
output:
html_document:
includes:
in_header: header.html
before_body: doc_prefix.html
after_body: doc_suffix.html
---
This would allow the combination of html and Rmd in general. Furthermore there is the chunk option child, which would allow to use Rmd files as chunk content?
You can use .css files to style your Rmakdown. In the header you do something like:
---
title: "Habits"
output:
html_document:
css: styles.css
---
see this
I want to use kramdown (with features such as fenced code blocks, inline attribute lists, header IDs) together with pygments for syntax highlighting (e.g. for LaTeX support, which is not available with CodeRay used by kramdown). Jekyll supports both kramdown and pygments, but apparently not the two together (unless I use Liquid tags which I would prefer not to).
I've also found some plugin snippets of how to make kramdown fenced code blocks spit pygments highlighted code, but unfortunately I don't know how to make that work.
I tried dumping all of the code from that site on some _plugins/krampygs.rb file, but then jekyll build complains about:
Generating... error: undefined method `matches'
If I supply some trivial matches and output_ext as instructed by Jekyll plugin docs, but then I don't know how to select this new converter for my .md files. Adding something like
markdown: MarkdownConverter
on my _config.yml only complains that this is not a valid option.
So, well, I restate my question: How can I use kramdown with pygments in Jekyll?
Solution
With the help of Matthias (below), I was able to prepare this Kramdown+Pygments plugin for Jekyll 1.x.
Author of "that site" here.
It depends on the Jekyll version. For the version when the post was written, that was enough. At least Jekyll 1.x requires that matches is defined in the MarkdownConverter, like so:
def matches(ext)
ext =~ /^\.md$/i
end
Another problem that appears with Jekyll 1.x is that every custom Markdown converter is ignored. I worked around this by by stating the output extension explicitly
def output_ext(ext)
".html"
end
and tell Jekyll that to look for a bogus Markdown extension by setting
markdown_ext: foo
in _config.yml.
I have updated the plugin created by Juan, to be compatible with Jekyll 2.x, along with some other improvements.
It can be found here: https://github.com/mvdbos/kramdown-with-pygments.git