How do I make syntax highlighting for a discuz template?

Source: Internet
Author: User

I have been doing ASP. NET development, recently received the task to use Discuz to develop a community, the first contact with php,php flexible grammar, natural modularity, a variety of grammatical sugar deeply shocked me, I feel from the heart of the PHP is the most awesome language!!!

Okay, back to the chase, first look at the discuz template, with VS Open is this:

Yes, at first glance it looked shocked, how is this TM maintained? Template casually on 2000 lines, because DZ is a very flexible forum, which put a variety of hook points for the expansion function! So the template is very large and complex.

The template syntax for DZ uses HTML annotation extensions (some of which are inline but destructive), see:

http://faq.comsenz.com/library/template/syntax/syntax_index.htm (DZ tag Syntax description)

My first idea is to give DZ a syntax highlighting function, the mind of the emergence of Lex YACC and other tools (the compilation principle forgotten almost but can remember them both.) )

I tried to develop a language extension in my skilled use of visual Stadio, and saw this article: making GLSL lexical coloring plug-ins with the Visual Studio SDK, touching the C # version of Lex---gplex,

So I also like to draw scoop, in the process of painting scoop, I also learned that since VS2015 Update1 start vs support the TextMate language extension specification!!! (This is to pick up the Mac ecology of the ready-made)

%userprofile%\.vs\extensions This directory is good. HTTPS://msdn.microsoft.com/en-us/library/ mt742400.aspxhttps://manual.macromates.com/en/language_grammarshttps: // Github.com/madskristensen/textmatebundleinstaller

--------------------------Toss N-hour divider line------------------------------------------------------------------

I finally found that the syntax for describing HTML with Lex was too cumbersome, I just extended the HTML with the HTML syntax highlighting, and didn't need to rewrite the lex description of the HTML, so I gave up vs to Microsoft's cross-platform editing artifact vs code!!

--------------------------Discard Visual Stadio----to the visual Stadio code security progress Divider------------------------------

Why use visual Stadio Code? Because this guy supports very many languages, itself is a Chrome browser, high imitation atom. And then check out how to expand VS Code, without having to tell me that it should also support the TextMate extension specification.

and vs a routine in the%userprofile%\.vscode\extensions folder to place the extension on the line

Look at the next Vscode document, found a Yo tool can use the wizard to generate syntax highlighting project, OK

Yo code

Quickly generate a, and then open the project directory with Vscode Press F5, enable a new Vscode, open the DZ template file in the new Vscode.

At this time because did not write any lexical analysis of dongdong, this should be ineffective.

So how do you write it?

Package.json is a manifest file that describes a vscode extension. Vscode 1.2 began to support a new feature called Syntax Injection (Injectto property)!!!

(This is what I want, inject my keywords into the HTML syntax!!) )

For example, I pointed out in the manifest file that I want to inject my own grammar into "text.html.base", (Text.html.base is a vscode built-in ScopeName, I debug Vscode, not mentioned in the official documentation)

You can see that I have written a keyword like if in this textmate language extension file, and of course I can extend the other. Press Ctrl+r Reload in the Vscode being debugged

It's much better than before.

The syntax in the inline string has no effect and needs to continue extending the property values in Text.html.base

Not to be continued

How do I make syntax highlighting for a discuz template?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.