Is it possible to add a real link in a code highlight block in Jekyll? - jekyll

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

Related

Markdown/html not parsing correctly in eleventy from frontmatter generated by Netlify CMS

I've been stuck on this for an embarrassingly long time. I have two inputs that aren't displaying correctly, a markdown widget and the list widget. They both appear as one long string. I thought I needed to add a markdown parser for the former at least so I'm using markdown-it in a manner similar to this:
https://github.com/11ty/eleventy/issues/236
It is adding paragraph breaks where they should be but they show up on the page as p tags. I thought this was because I already had the parsed text nested between p tags but if I delete those nothing shows up at all. When I look at the html file created by eleventy, the tags show up as "&lt ;p&gt ;" (without the spaces) which it seems the browser isn't reading correctly when trying to interpret the html. I'm using nunjucks for templating if that matters. My .eleventy.js file looks like this currently. What am I missing? Also the markdown filter seems to only want to take a string so I'm not sure where to even begin with the list.
By default, Nunjucks HTML-escapes all variables when outputting templates. This is what you want most of the time, unless you're trying to render HTML input.
You might want to try using the safe filter after your markdownify filter.
{{ markdownContent | markdownify | safe }}

How to stop inline HTML comments from going to the next line when using Reformat Code in PHPStorm?

I am using PHPStorm IDE and in the meanwhile I also use HTML comments for the ending tags.
I use Reformat Code by cmd+alt+L keys a lot. I am aware that the Code Style in Preference will change the code style when using Reformat Code. However, it seems that I cannot change the HTML comments which are in the same line as HTML ending tags from going to the next line when I use Reformat Code feature which is annoying.
How can I change that to have the HTML comments inline with HTML ending tags when using Reformat Code feature?
AFAIK there is no such option.
https://youtrack.jetbrains.com/issue/WEB-5070 -- star/vote/comment to get notified on progress.

Showing certain tags django templates

If I want to be able to show only certain tags in (say as in a forum post) using django tempalte variables how would I do that?
Say the content of my post is:
<div><b>Hell</div>o <i>everyone</i></b>
I don't want to show the div tags, but the b and i tags are fine. I know you can use |safe and autoescape but that seems to escape all html. Is there a better way to do this?
You could use a Custom Django Filter with a Regular Expression that does this.
Have a look here: http://djangosnippets.org/snippets/60/ replace the Regular Expression with what you need to remove the HTMl tags you don't want.

HTML page title: localization and empty title

2 questions about a better way of solving the problem:
1) is there is a way to make HTML page title looking different for different locales of the client-side code except for javascript?
I.e. write HTML page title which is shown in the browser's tab in corresponding language.
I know I can use javascript for this, but may be there is another way?
2)I set my HTML page header with javascript (it is a different case). But there is a delay before the script will run. Is there is a way to set HTML page header to empty line before javascript evaluates?
If I remove tag I get the page URL.
If I use empty tag - same thing.
I have to use &nbsp content inside which looks a bit ugly.
Some other options?
I don't see any other means but JavaScript on the client side for this, sorry.
For the delay: try using an inline javascript to change the page title right on top of the page before any other scripts are loaded or executed, but after the page title has been set. This should keep the delay to an absolute minimum.
To the first:
Except Javascript, the only Way i know would be PHP, but using Javascript is a lot better and
easier.
To the second:
arkascha's Post is the answer

How to display source code with indent in a web page? HTML? CSS?

I want to show some source code with the WebBrowser control on a winform. And I want to decorate the source code with HTML tags, such as color, font, and size. But I found it difficult to display the indent properly.
To be precise, my source code are held in String[], and each String holds the proper indent (space or tab) already. But it seems these kinds of indent are just ignored by the WebBrowser control.
Could someone tell me how to?
I like to paste my code in a Gist and then display it that way. Github will recognize the code and format it accordingly.
If you're going to be doing it often you could try markdown.
Or use a one-off formatter like Syntax Highlighter.
The <pre> element (using <code> elements with appropriate class names to mark up the parts you want to syntax highlight)
<pre><code class="javascript"><code class="keyword">function</code> <code class="name">foo</code>()…
You might want to look into this JavaScript library to highlight and format your code. http://code.google.com/p/syntaxhighlighter/
Or you can check out a service like this - http://pygments.appspot.com/ or this - http://hilite.me/