Is there a way to include custom functionality in the razor engine to augment the functionality it has?
For instance, if I wanted to use:
$(This is my text)
instead of
<text>This is my text</text>
Is there a way to do this?
Instead of
<text>This is my text</text>
You can have
#:This is my text
This is how I do string literal without having to use the <text>...</text> tags. This is already provided by razor unless you want something else?
Related
How do I render a strikethrough (or line-through) in an adoc file?
Let's presume I want to write "That technology is -c-r-a-p- not perfect."
That technology is [line-through]#crap# not perfect.
As per Ascii Doc manual, [line-through] is deprecated. You can test here.
Comment from Dan Allen
It's important to understand that line-through is just a CSS role. Therefore, it needs support from the stylesheet in order to appear as though it is working.
If I run the following through Asciidoctor (or Asciidoctor.js):
[.line-through]#strike#
I get:
<span class="line-through">strike</span>
The default stylesheet has a rule for this:
.line-through{text-decoration:line-through}
You would need to do the same.
It is possible to customize the HTML that is generated using custom templates (Asciidoctor.js supports Jade templates). In that case, you'd override the template for inline_quoted, check for the line-through role and produce either an <s> or, preferably, a <del> instead of the span.
If you're only targeting the HTML backend, you can insert HTML code verbatim via a passthrough context. This can be done inline by wrapping the parts in +++:
That technology is +++<del>+++crap+++</del>+++ not perfect.
This won't help you for PDF, DocBook XML, or other output formats, though.
If the output is intended for HTML you can pass HTML.
The <s> HTML element renders text with a strikethrough, or a line
through it. Use the element to represent things that are no longer
relevant or no longer accurate.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/s
To render as:
Example text.
use:
1. Pass inline:
Example +++<s>text</s>+++.
2. Pass-through macro:
Example pass:[<s>text</s>].
3. Pass block:
++++
Example <s>text</s>.
++++
I know how to work with namespaces in Nokogiri, but sometimes, I want to look at how the document is actually specified.
In those cases, it would be nice if Nokigiri could simply act like it knows nothing about namespaces, treat "xmlns" just like any other attribute, and treat elements as if their names are exactly as written (colons and all, when present) and all in the default namespace.
Is there a way to achieve that?
EDIT: Add example
So let's say I'm using Nokogiri to check generated SVG. I want to know that the namespace was specified in the root element using the xmlns attribute, and I want to know that the sub-elements use implicit name-spacing.
<svg version="1.1" width="300" height="200" xmlns="http://www.w3.org/2000/svg">
<path d="M 10,10 l 5,20" />
</svg>
If I parse that using Nokogiri, then I can find the "path" element as follows:
svg_doc.xpath('//ns:svg/ns:path', 'ns' => "http://www.w3.org/2000/svg")
That shows me that the file is "correct" in terms of resulting in elements with the expected namespaces, but doesn't let me know anything about how that namespacing was specified.
If I could get a document instance that is completely ignorant of namespaces, then…
I could inquire about the "xmlns" attribute value using svg_doc.root['xmlns']…
and I could find that there is a "path" element child of the "svg" root element and that neither element has namespace qualifier prefix using svg_doc.xpath('//svg/path').
In the "Namespaces" section of "Searching an HTML / XML Document" is the part about using CSS selectors:
Don’t be fooled though. You do not have to use XPath to get the benefits of namespaces. CSS selectors can be used as well. CSS just uses the pipe symbol to indicate a namespace search.
Let’s see the previous search rewritten to use CSS:
#doc.css('xmlns|title') # => ["<title>Example Feed</title>", "<title>Atom-Powered Robots Run Amok</title>"]
When using CSS, if the namespace is called “xmlns”, you can even omit the namespace name. That means your CSS will reduce to:
#doc.css('title') # => ["<title>Example Feed</title>", "<title>Atom-Powered Robots Run Amok</title>"]
I'm writing a Module for Joomla! 2.5. In my Backend I've got a textarea, in which values should be written line by line. If the value is to big the line breaks and it looks really confusing and chaotic.
In normal html I would add a wrap="off" to the textarea-tag (I know it's not conform html, but it works), but the textarea is defined in the module's xml-file:
<field name="content" type="textarea" label="LWTAGCLOUD_CONTENT_LABEL" description="LWTAGCLOUD_CONTENT_DESCRIPTION" rows="20" cols="60" class="lw_tagcloud_textarea" default="VALUE; LINK"></field>
Has anyone an idea how to solve this problem?
If you cannot solve the problem using css only, and since you cannot add wrap="off" to the textarea type in Joomla, what you could do is to create a custom parameter type, the same like textarea, just with wrap=off already defined.
For more details on how to do it, have a look at http://docs.joomla.org/Creating_custom_template_parameter_types and http://www.sanjeevshrestha.com.np/2010/01/creating-color-element-in-joomla-for-custom-parameter-type/, it's not hard to make it
just use
for line break !
hope this help for anyone who ask
I've been doing development in TWIG lately. It is an html templating language that is very simple and robust.
I've set notepad++ to automatically treat .twig files as html. This is ok, but I don't get any syntax highlighting on my twig functions.
The twig syntax is incredibly simple (by design) and would be easy to add to notepad++. The problem is, everything I find on this subject is either about creating a new language definition (and I do not want to reinvent the html definition), or modifying the color for existing syntax bits in a language.
Is there any way to copy a language definition and then modify it in notepad++? If not, is there any way in notepad++ to add extra syntax bits to an existing language definition?
edit
TWIG is an html template language/engine. they syntax for it is the same as html, with the addition of a few open/close tags (specifically {% %}, {{ }}, and {# #}) for control statements. you can read more about it at the twig website
edit #2
Based on the answer from Brian Deragon, I have been investigating 3 files. Heres what I've figured out/done so far:
\plugins\APIs\html.xml - Seems to define keywords, for autocomplete. I made a copy of the file named twig.xml
langs.model.xml - Again, a list of keywords, with all the languages in 1 XML file. I copied the HTML object and replaced the name and ext parameters with twig.
stylers.model.xml - Has a list of different items, and style information (color, bg color, font, etc) for each. I copied the HTML section and changed the name and desc parameters to twig.
Those changes done, I opened up a twig file in notepad++, hoping to see it listed in the language options. Sadly, it has not appeared, leading me to believe that some of this is hard coded (and thus what I want might not be possible).
The stylers.model.xml is interesting, though. Each entry has a bunch of items, defined like this:
<LexerType name="twig" desc="TWIG" ext="">
<WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
<WordsStyle name="COMMENT" styleID="9" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAG" styleID="1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WordsStyle name="TAGEND" styleID="11" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
...
</LexerType>
Those seem to be where the styles are defined for the different elements. I can't find anywhere where those elements are defined though. langs.model.xml has a definition for comment start/end, but not for any other delimiters. what I really need is a place to tell notepad++ to treat { } as a delimiter, much like it does for < > now.
edit #3
I am also looking at this list of user defined languages for notepad++ http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Language_Files
User defined languages use a different engine, but i might be able to find one in there that is similar to html enough that I can adapt it.
You should be able to just copy and edit the XML definition file (html.xml); as long as you don't need stuff beyond the basics, like code-folding, advanced coloring based off of case-handling blocks or multiple conditionals, separate formatting for lead characters, label coloring, xml-based commenting, language mixing (coloring of embedded scripts), support for coloring of duck-types, etc. If you need anything "advanced" you need to write your own lexer, in which case most of the below applies.
Even still, the templates I listed below should give you a head-start on your own language definition file.
As far as I'm aware, Notepad++ uses Scintilla Lexers for determining its code rules.
You'll have to create your own lexer, but...the HTML Scintilla Lexer is already included in the Scintilla source code.
Then you would insert your custom lexer using a plug-in, like Gary's Lua Highlighter Plugin.
Resources for building a custom lexer:
How to write a scintilla lexer
That being said, Geany is very similar to Notepad++ (based off the same engine, Scintilla), so you might want to see whether it's already been done for Geany, or whether there's an open-source project for it in the works. This would at least give you a head start.
If that doesn't help, there are IDEs and editors with Twig support built-in, like:
Eclipse
Netbeans
GEdit (which has a Windows binary, if needed)
JetBrains PhpStorm
GEdit has published their XML definition of the language here, which might help as a reference when creating your own definition file or lexer; there's also another template published by the guys from Twig here that might be of some help.
Here are the best Notepad++-specific tutorials for creating custom lexer's/User Defined Languages I can find:
User Defined Languages
How to create a user-defined language in Notepad++ based on an existing language?
If you want to get brave and build your own Scintilla dll, reference these threads, to see a guy who got it working, and to show up in the language list (use the previous/next thread message to see responses, or the thread index; it's a mailing list, so its UI isn't the best)
http://osdir.com/ml/editors.notepad++/2007-02/msg00021.html
Hope that helps or gets you at least more of a head start!
I made a Highlighter for it here:
https://github.com/Banane9/notepadplusplus-twig
Possible duplicate of this post: https://superuser.com/questions/40876/assigning-custom-extensions-to-a-languages-syntax-highlighting-in-notepad
All you need to do is add your custom extension in Settings->Style Configurator
Click on HTML and add your extension in the User Ext box.
EDIT: If you want to add more rules to your language, you might have to add another XML in notepad++->plugins->APIs
If you think it's like HTML, just copy over html.xml and save as twig.xml
Add more rules to this XML file
Consider this:
<img style="INFO" alt="INFO" src="INFO" target="INFO" onmouseout="INFO" />
How can I target every attribute (style, alt, src etc.) within the IMG tag to validate it against a white-list?
You should use a DOM parser for that. Depending on what language you are using there are different library that you can use for that.