Changing code sample format for nasm code samples in Jekyll - jekyll

I'm using Jekyll with the minima theme.
In a recent post I made, someone pointed out to me that I can use nasm specific formatting with ~~~nasm - it's good to know that nasm is a supported language!
However, the syntax highlighting is pretty ugly, look at the red glow around the square brackets:
It it incorrectly indicating a syntax error, due to this bug.
Is it possible to override the style for those brackets and other aspects of the code samples?

Save https://raw.githubusercontent.com/jekyll/minima/master/_sass/minima.scss to _sass/minima.scss
Save https://raw.githubusercontent.com/jekyll/minima/master/_sass/minima/_syntax-highlighting.scss as _sass/minima/_syntax-highlighting.scss
You can now modify your syntax highlighting in _sass/minima/_syntax-highlighting.scss.

Related

How can we make pandoc produce pretty, human readable HTML from markdown?

Recently I realized that I had made a bad choice by writing my notes in Markdown. I wanted to switch to HTML instead and put it on my website.
I used pandoc for converting the file from html to markdown:
pandoc file.md -o file.html
But everything seems wrong about this (snippet from vim):
Problems:
Code is not readable. It was very, very readable in Markdown, but I'm not sure what's up with character codes showing up instead of something humans can read.
Indentation is weird. I just did indentation with the usual gg=G in vim, and it seems that all the <p> tags are being gradually indented further and further to the right. Is this expected behaviour? It certainly looks ugly.
Specific things about the HTML code are undesirable. This is probably the least vexing, since you can easily replace things with substitute, but since I am planning on using prism for code highlighting, I would like things like class="language-c++" instead of class="sourceCode cpp.
Question: Is there any way to easily fix up this mess, or have pandoc generate better in the first place? Is there a substitute that works better than pandoc? Is there a pandoc option that I am missing?
By "character codes" I assume you mean > and the like. These are necessary in HTML, since a < character has a special meaning. Without these escapes you'd have invalid HTML.
Indentation: pandoc does not indent its HTML output. So this is the result of something you did in vim. It's not a pandoc issue.
Code formatting: By default, pandoc inserts classes and span tags to create highlighted HTML for code blocks. If you don't want this (e.g. if you want to do your own highlighting with some JavaScript code) then you can disable it using --no-highlight. You may still get some transformation of class names. You can change these using a simple lua filter: see the documentation for lua filters.

Changing colorschemes in vim disables syntax highlighting for html

So yeah, the question is in the title. The situation is that, imaging one vim window split into one half of html and the other half css. When I change the colorscheme from say Badwolf to molokai, the syntax coloring on the html disappears. Any reasons why?
When I change the colorscheme it seems that only html filetypes is affected (as css syntax highlighting is still present), and most colorschemes don't highlight the syntax. examples include molokai, monokai, etc with exceptions being badwolf and gruvbox.
Do you guys think this is a bug or is there something wrong with my _vimrc? Really don't wanna go through 100+ lines of code all neatly folded last night :(

Fix Html / Xhtml Markup Errors?

Is there a tool to help fix Html errors and warnings? I just checked my code against the W3 Validator and found hundreds of errors and warnings.
Preferably something that can work with php
You can give HTML Tidy a try. I don't know about PHP, but there seems to be an extension for HTML Tidy here.
However, I recommend that you try to fix the errors/warnings yourself because this way you'll learn how to write valid HTML. You'll find that fixing a single error will usually cause a chain reaction of fixes.
If you are validating your code, you must double check what doctype you used. If you are using strict you must know which elements will work with it. For instance, according to strict iframes are invalid but in transitional they are accepted. This should help you get rid of some or most of your errors. The validator tells you what the error is and an idea of how to fix it. I would suggest looking through it and fix your errors one by one.
I also recommend getting a program called Notepad++. It is a free text editor that makes it easier to recognize errors by color coding your code. There is another program called HTML validator that is a text editor / validator combined. It also color codes your code and it has a built in validator. You can get a free trial but the full version costs between $60 and $90.
I have not come across a validator for php, although HTML validator may also help with php as well. Hope this was helpful.

Can Vim highlight matching HTML tags like Notepad++?

Vim has support for matching pairs of curly brackets, parentheses, and square brackets. This is great for editing C-style languages like PHP and JavaScript. But what about matching HTML tags?
Notepad++ has had this feature for as long as I’ve been using it. Being able to spot where blocks of HTML begin and end is very useful. What I’m looking for is something like this for Vim (see the green div tags):
A bonus feature: highlighting unclosed HTML tags, like the red tag in the above screenshot.
matchit has been proposed as the next-best-thing, but it requires an extra keystroke to use its functionality. I’d like be able to see where the blocks of HTML begin and end without an extra keypress.
I’ve trawled the internet to find something like this for Vim. Apparently, I’m not the only one, according to two other StackOverflow questions and a Nabble thread.
I’ve almost resigned myself to Vim not being able to visually match HTML tags. Is it possible for Vim to do this?
Addendum: If it is not currently possible to do this with any existing plugins, does any Vimscript wizard out there have any pointers on how to approach writing a suitable plugin?
I had to work with some HTML today so thought I would tackle this. Added a ftplugin to vim.org that should solve your problem.
You can get it here on vim.org.
You can get it here on github.
Hope it works for you. Let me know if you have any problems.
Greg's MatchTag.vim plugin is awesome, but I wanted something more. I wanted the enclosing tags to always be highlighted, not just when the cursor is on one of the tags.
So I wrote MatchTagAlways which does everything that Greg's MatchTag does and also always highlights the enclosing tag, no matter where the cursor is in the code. It also works with unclosed tags and HTML templating languages like Jinja or Handlebars.
Here's a GIF showing it in action:
I came here looking for matching html style angle brackets in Vim. This seems to work:
:set mps+=<:>
:help matchpairs

Tag <code>: how to "correct" publish it?

i'm not sure to explain what i'm looking for.
What's the name of the "source code parser" for publish code, in HTML ?
For example, when i write some source code here in stack overflow, system auto-detect the sintax and write "correct" source code in html.
I've noticed that exists the HTML <"code"> tag, but it simply write source code in "courier" font.
So i'm asking you if exists some "external" component that, given a text, parse it out correctly in a HTML page.
Thank you!
SO uses prettify to syntax highlight the <code> snippets.
Source: Which tools and technologies were used to build the Trilogy?
It is a JavaScript tool that scans a page for code snippets, and colours them on the fly. The downside of this solution is that it doesn't work with JavaScript turned off. Seeing as syntax colouring is not really an essential task, it is arguably a small downside.
The system is called Markdown and here is an explanation of the code blocks it uses.
For the syntax highlighting that you mentioned, a different system is used called prettify.
There are two components to this:
The CSS/HTML structure for syntax highlighting (e.g. styles for printing keywords, #s, strings, comments etc... in certain colors). This can be generic or per-language.
The code parser (grammar parser), which breaks the code up into tokens and labels the tokens with the appropriate classes. This can be implemented on either back-end via whatever language your back-end is in; or on front-end via JavaScript (the example of the latter is Google's Code Pretty which is used by StackOverflow).
It can be coupled with some heuristic logic to decide what language the code belongs to (and thus which grammar/parser to use).