Henning Schröder avatar Henning Schröder committed a2ee015

updated docs

Comments (0)

Files changed (4)

 
 Unlike libraries like Pygments there is no need to retokenize the
 whole text after a small change. 
-Instead is has a state machine mechanism which is directly supported
+Instead it works using a state machine mechanism which is directly supported
 by QSyntaxHighlighter. 
 
 It uses a concept from Eclipse where the source is separated into
 
 Unlike libraries like Pygments there is no need to retokenize the
 whole text after a small change. 
-Instead is has a state machine mechanism which is directly supported
+Instead it works using a state machine mechanism which is directly supported
 by QSyntaxHighlighter. 
 
 It uses a concept from Eclipse where the source is separated into
 the GUI.
 
 
-Contents:
+    
+How to get it
+-------------
+
+The latest snapshot is available at:
+  
+    https://bitbucket.org/henning/syntaxhighlighter/get/tip.tar.bz2
+    
+    
+To clone the Mercurial repository do::
+
+   hg clone https://bitbucket.org/henning/syntaxhighlighter
+      
+      
+Or just got to the BitBucket overview page:
+
+   https://bitbucket.org/henning/syntaxhighlighter
+
+
+
+More info
+---------
 
 .. toctree::
    :maxdepth: 2
    
    usage
-   
-   
-How to get it
--------------
-
-The latest snapshot is available at::
-  
-    https://bitbucket.org/henning/syntaxhighlighter/get/tip.tar.bz2
-    
-    
-To clone the Mercurial repository do::
-
-    hg clone https://bitbucket.org/henning/syntaxhighlighter
-      
-      
-Or just got to the BitBucket overview page: https://bitbucket.org/henning/syntaxhighlighter
-
 
 
 Indices and tables
 
 
 As you see the lists, tuples and dicts get converted into
-Format, Partion, PartionScanner, Token and Scanner instances.
+Format, Partition, PartionScanner, Token and Scanner instances.
+
+
+Predefined highlighters
+=======================
+
+The package already contains a full Python and a Javascript highlighter.
+
+The following code snippets shows how to use the Python highlighter.
+
+.. code-block:: python
+
+  from highlighter.python27 import syntax
+  from highlighter import SyntaxHighlighter, load_syntax
+
+  scheme = {
+    "syntax_comment": dict(color="green", italic=True),
+    "syntax_string": "magenta",
+    "syntax_builtin": "red",
+    "syntax_keyword": ("darkred", True),
+    "syntax_number": "blue",
+  }
+  
+  
+  parts_scanner, code_scanner, formats = load_syntax(syntax, scheme)
+  ...
+  hl = SyntaxHighlighter(edit.document(),
+     parts_scanner, code_scanner, formats, default_font=font)
+
+
+Besides python27 there is also a python32 module. The Javascript
+highlighter definition is in highlighter.js
 
 
 if __name__ == "__main__":
-	from PyQt4.QtGui import QApplication, QPlainTextEdit
-	app = QApplication([])
-	edit = QPlainTextEdit(None)
-	sh = SyntaxHighlighter(edit.document(), ps, {"tag":tag_scanner}, [
-	      comment_fmt, tag_fmt, text_fmt, attr_fmt, value_fmt], default_font=edit.font())
-	edit.resize(800, 600)
-	edit.setPlainText('<!-- comment--> text <tag attr="value">')
-	edit.show()
-	app.exec_()
+    from PyQt4.QtGui import QApplication, QPlainTextEdit
+    app = QApplication([])
+    edit = QPlainTextEdit(None)
+    sh = SyntaxHighlighter(edit.document(), ps, {"tag":tag_scanner}, [
+          comment_fmt, tag_fmt, text_fmt, attr_fmt, value_fmt], default_font=edit.font())
+    edit.resize(800, 600)
+    edit.setPlainText('<!-- comment--> text <tag attr="value">')
+    edit.show()
+    app.exec_()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.