HAML Syntax highlighting misalignment - html

Hoping this is a quick fix,
I have a some HAML I would like to have highlighted with the prism library.
%pre
%code.language-haml
%header.post-header
%h1= data.title
%time{ datetime: data.date }= pretty_date(data.date)
only it's coming out like this
how do I get it to look like this
it's pretty frustrating, if I leave it unescaped it will not be visible.

I eventually just hacked it using the HTML escape HTML code for spaces and then aligned them all using that.

Related

<br> does not break line in kableextra Rmarkdown HTML when there is a < character

So I have a tibble. assume that I have this string in a cell : cases(>20yo), cases(<20yo) other
I try cases(>20yo), cases(<20yo) <br> other . but other does not go to the next line in html output. it only works if I replace < in <20yo.
is there any reason behind this? how can I fix this. I am not bring the code since it does not show the output anyways and I assume this is a general question rather an a code specific. Thanks

Prevent HAML from rendering newline in produced HTML file

I have this HAML code:
%p
This page is for our staff. If you came here by mistake,
%a(href="index.html") you can go back
\.
The isolated \. is there because I don't want the full-stop (.) to be part of the link.
This almost works but there is a space between back and .; naturally, HAML is inserting the newline in the HAML source code in the HTML rendered file.
In other words, this is the HTML produced:
<p>
This page is for our staff. If you came here by mistake,
you can go back
. <!-- I want the period to be on the previous line -->
</p>
Because words inside the <p> tag are separated by a space, there is a space between back and .. How can I remove this space?
I found one way to do this, but it is ugly (or I won't have asked this question):
%p
This page is for our staff. If you came here by mistake,
%a(href="index.html") you can go back
%span>\.
Is there a better way to do this?
HAML accepts plain html, so you could write:
%p
This page is for our staff. If you came here by mistake,
you can go back.
Which will give you the output you need.
You can also use the succeed helper for this, although it reads a little funny:
= succeed '.' do
%a(href="index.html") you can go back
Will produce:
you can go back.\n
So full example would be like:
%p
This page is for our staff. If you came here by mistake,
= succeed "." do
%a(href="index.html") you can go back
Rendered Output:
<p>
This page is for our staff. If you came here by mistake,
<a href='index.html'>you can go back</a>.
</p>

Turn html text into markdown manually (javascript / nodejs)

I'm a bit stuck. I have scraped a website and would now like to convert it into markdown. My html looks like this:
Some text more text, and more text. Some text more text, and more text.
Once in a while <span class="bold">something is bold</span>.
Then some more text. And <span class="bold">more bold stuff</span>.
There are html to markdown modules available, however, they would only work if the text <b> looked like this </b>.
How could I go through the html, and everytime I find a span which is supposed to bold something, turn this piece of the html into bold markdown, that is, make it **look like this**
Try this one https://github.com/domchristie/to-markdown, an HTML to Markdown converter written in JavaScript.
It can be extended by passing in an array of converters to the options object:
toMarkdown(stringOfHTML, { converters: [converter1, converter2, …] });
In your case, the converter can be
{
filter: 'span',
replacement: function(content) {
return '**' + content + '**';
}
}
Refer to its readme for more details.
Notepad++ is an open-source editor that supports regex. This picture shows the basic idea.
You know how to use an editor to find and replace strings. In an editor like Notepad++ you can look for string patterns and replace parts of the patterns and keep what's left. In your case, you want to find strings that are framed by HTML markup. Here the regex in the 'Find what' edit box displays that, with the special notation ([^<]*) meaning save zero or more of any character other than the '<' for use in a replacement string. The 'Replace with' edit box says used what was saved (as \1) in the expression **\1** which gives you what you prefer to have in the text file. It remains to click on 'Replace all'.
To be able to do this you need to install Notepad++ and learn some basic Perl regex. To get this dialogue box click on Ctl-H. Of course, if you get it wrong there's always Ctl-Z.

ruby tags for Sphinx/rst

I create HTML documents from a rst-formated text, with the help of Sphinx. I need to display some Japanese words with furiganas (=small characters above the words), something like that :
I'd like to produce HTML displaying furiganas thanks to the < ruby > tag.
I can't figure out how to get this result. I tried to:
insert raw HTML code with the .. raw:: html directive but it breaks my line into several paragraphs.
use the :superscript: directive but the text in furigana is written beside the text, not above.
use the :role: directive to create a link between the text and a CSS class of my own. But the :role: directive can only be applied to a segment of text, not to TWO segments as required by the furiganas (=text + text above it).
Any idea to help me ?
As long as I know, there's no simple way to get the expected result.
For a specific project, I choosed not to generate the furiganas with the help of Sphinx but to modify the .html files afterwards. See the add_ons/add_furiganas.py script and the result here. Yes, it's a quick-and-dirty trick :(

Yahoo Pipes and Regex with an html formatting issue

I am struggling to see how to use the regex to add a non-printable carriage return character into an html string.
Its a WordPress thing in that to auto-embed a video I need to put the URL on its own line in the html.
First I use a regex:
In item.vid_src replace ($) with \\r$1
s is checked.
After which I am using a loop with a string builder in it - I am prefixing vid_src to the start of description thus:
item.vid_src
<br><br>
item.description
assign results to item.description
Before I include the Regex module in the pipe I get this:
http://www.youtube.com/watch?v=THA_5cqAfCQ<br><br><p><h1 class="MsoNormal">Cheetahs on
the edge</h1>
But I need this:
http://www.youtube.com/watch?v=THA_5cqAfCQ
<br><br><p><h1 class="MsoNormal">Cheetahs on the edge</h1>
Adding the regex module I get this:
http://www.youtube.com/watch?v=THA_5cqAfCQ\r<br><br><p><h1 class="MsoNormal">
Cheetahs on the edge</h1>
Clearly its inserting exactly what I have asked for, but It is not what I was expecting, I need to get the html formatted with the newline. Does anybody have an insight as to how to tackle the problem?