Comments (5)
Language tags should be easy to recognize and remember.
Since we use class="prettyprint" to identify regions to prettyprint, I suggest
the
following convention
class="prettyprint" -- make a best guess as to language
class="prettyprint lang-java" -- do java prettyprinting
The "lang-" prefix is followed by the filename extension commonly used for
source
files in that language to avoid problems with C# not being a valid html
identifier.
We will use cc for C++ since it is an identifier, and more commonly used than
cpp or cxx.
Original comment by [email protected]
on 15 Aug 2007 at 6:57
from google-code-prettify.
To flesh out the high level design, the prettify loop will be changed to:
(1) Extract tags and store [tag, position-in-string]
(2) Use a regex based lexer to lex the string sans tags
(3) Run a classifier over tokens
(4) Merge tags back into token list and join tokens to produce html
from the current
(1) Split into chunks of tags | text
(2) Split text chunks into tokens using a state machine over a character
iterator
that unescapes entities lazily
(3) Join token list to produce html
This will cut out the hand coded state machines that iterate over characters,
replacing them with the regex based lexers from 2.
We can then define a language handler as a { lexer, classifier } pair.
Define a language handler for C-style langs and one for markup langs to get us
backwards compatible.
Modify the main prettify function to look for a lang-\w+ class, and, if present,
choose the appropriate lexer.
Implement a lisp/scheme lexer to demonstrate that new handlers can be added and
document.
Implement other lexers as demanded.
Original comment by [email protected]
on 15 Aug 2007 at 8:43
from google-code-prettify.
Finished rewriting the existing lexers to use PR_createSimpleLexer which is
regexp based.
Original comment by [email protected]
on 31 Aug 2007 at 8:49
from google-code-prettify.
I realize this would be an entirely different thing, but what about taking
advantage
of a library of pre-written syntax highlighting rules, like VIM's? The
syntax-defining commands aren't that complicated. (Well, they don't seem to be,
what
do I know?)
Original comment by [email protected]
on 7 Feb 2008 at 11:34
from google-code-prettify.
@r38
Original comment by [email protected]
on 5 Jul 2008 at 4:04
- Changed state: Fixed
from google-code-prettify.
Related Issues (20)
- Perl syntax highlighting does not recognize POD and highlights quotes in comments
- Bash "$#" treated as comment HOT 1
- Integration for Presentation
- Patch for /trunk/src/lang-css.js
- "><img src=x onerror=prompt(1);> HOT 2
- Feature request: AspectJ syntax highlighting.
- gzip disabled
- Patch for /trunk/js-modules/run_prettify.js
- Patch for /trunk/src/lang-vb.js
- Line numbers carry over in clipboard using IE 11.
- Patch for /trunk/src/awkirin.css
- Problem with backslash in VB
- FLOW_CONTROL_KEYWORDS should not contain `do`
- Syntax Highlighting for Rebol (and Red) programming languages
- Patch for /trunk/styles/sons-of-obsidian.css
- Syntax highlight for Robot Framework syntax
- Patch for /trunk/src/prettify.css HOT 1
- Inconsist TCL Syntax higlighter
- Patch for /trunk/src/lang-sql.js
- Patch for /trunk/styles/sons-of-obsidian.css
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-code-prettify.