everything works fine, but with a parameter version it fails. If I do double-escaping the rehex will not match anymore.
If I put the regex (without double-escaping) on the shortcode parameter it will not match correctly, some parts are matched, some not.
My original shortcode is found here the three variables should be passed by a parameter.
First off, kudos on an awesome framework for including example code into your site.
The issue is that within the shortcode itself, the Go template engine is parsing the string, and it must be escaped.
When passing the regexp as a parameter to a shortcode, our shortcode parser handles that, and the parameters are treated a literal strings that don’t need to be escaped. So, use this:
Thanks for your compliment. It will work with your solution, but I add also a default option for reducing tag complexity.
I will publish the whole source of the shortcode here to read any source code from a GitHub repository:
I’m using Prism.js for syntax highlighting and coloring with the line-number plugin (which is loaded inside the header partial). But keep in mind the GitHub API Limit for getting content during developing and disabled caching it will reached very fast.
prefix is an optional first line inside the code base e.g. an open XML tag
postfix similar to prefix but for the last line e.g. a closing XML tag
linenumbers enable line-numbers of the source code
branch GitHub repository branch which should be used (default is master)
user the GitHub username
repo the repository name of the user
file the path to the file within the repository
clear a regular expression which removed anything that matches e.g. document strings
replace and replacewith replaces an elements that matches the expression with the other element e.g. multiple empty lines
filter and result a regular expression to grep a set of lines from the source code for each match a new code element will be created and result will limit the number of elements (default 1)
In my case I’m using an own language definition “agentspeak” with special layout definition, so I have added an if-else condition for that.
Additional to the code shortcode, I create a line-link shortcode base on the Line Highlight plugin to reference / highlight source code lines: