DOS format file (XSHD) for SharpDevelop, IMHO Instant Blogger, etc. - Jon Galloway

DOS format file (XSHD) for SharpDevelop, IMHO Instant Blogger, etc.

I use IMHO Instant Blogger to edit and post blog articles. One of my favorite features is the code snippet editor. It's built on the SharpDevelop text editor, which has support for language syntaxes which are defined in xml syntax highlight definitions (XSHD's). It's a nice way to show color coded source code on a web page.1

I post enough DOS scripts that I finally wrote a syntax file for the DOS Batch grammar. It's probably not 100% complete, but I grabbed the cammand from the DOS help command, some standard EXE's from c:\windows\system\, etc. It's easy to install for IMHO:

1. Save this text as C:\Program Files\Elite Agency\Imho Instant Blogger\formatters\CodeSnippet\styles\DOS-mode.xshd:

<?xml version="1.0"?>
<!-- 
syntaxdefinition for DOS Batch by Jon Galloway -->

<
SyntaxDefinition name "DOS" extensions ".cmd;.bat">
    
    <
Properties>
        <
Property name="LineComment" value="::"/>
    </
Properties>
    
    <
Digits name "Digits" bold "false" italic "false" color "DarkBlue"/>
    
    <
RuleSets>
        <
RuleSet ignorecase "true">
        
            <
Delimiters>~!%^*()-+=|\#/{}[]:;"'&lt;&gt; , .?</Delimiters>
        
            
<Span name "LineComment" bold "false" italic "false" color "Teal" stopateol "true">
                <
Begin>::</Begin>
            
</Span>
            
            <
Span name "LineComment" bold "false" italic "false" color "Teal" stopateol "true">
                <
Begin>rem</Begin>
            
</Span>
            
            <
Span name "Label" bold "true" italic "true" color "DarkBlue" stopateol "true">
                <
Begin>:</Begin>
            
</Span>
            
            <
Span name "String" bold "false" italic "false" color "Magenta" stopateol "true">
                <
Begin>"</Begin>
                
<End>"</End>
            
</Span>
            
            <
Span name "Char" bold "false" italic "false" color "Magenta" stopateol "true">
                <
Begin>&apos;</Begin>
                <
End>&apos;</End>
            </
Span>
            
            <
Span name "EnvironmentVariable" bold "true" italic "false" color "Blue" stopateol "true">
                <
Begin>%</Begin>
                
<End>%</End>
            
</Span>
            
            <
MarkPrevious bold "true" italic "false" color "MidnightBlue">(</MarkPrevious>
            
            <
KeyWords name "Punctuation" bold "true" italic "false" color "Black">
                <
Key word "?" />
                <
Key word "," />
                <
Key word "." />
                <
Key word ";" />
                <
Key word "(" />
                <
Key word ")" />
                <
Key word "[" />
                <
Key word "]" />
                <
Key word "{" />
                <
Key word "}" />
                <
Key word "+" />
                <
Key word "-" />
                <
Key word "/" />
                <
Key word "*" />
                <
Key word "&lt;" />
                <
Key word "&gt;" />
                <
Key word "^" />
                <
Key word "=" />
                <
Key word "~" />
                <
Key word "!" />
                <
Key word "|" />
                <
Key word "&amp;" />
            </
KeyWords>
            
            <
KeyWords name "Literals" bold="false" italic="false" color="Black">
                <
Key word "false" />
                <
Key word "true" />
            </
KeyWords>
            
            <
KeyWords name "IterationStatements" bold="false" italic="false" color="Navy">
                <
Key word "do" />
                <
Key word "for" />
                <
Key word "while" />
            </
KeyWords>
            
            <
KeyWords name "ManagedIterationStatements" bold="false" italic="false" color="Navy">
                <
Key word "foreach" />
                <
Key word "in" />
            </
KeyWords>
            
            <
KeyWords name "JumpStatements" bold="false" italic="false" color="Navy">
                <
Key word "break" />
                <
Key word "continue" />
                <
Key word "goto" />
                <
Key word "return" />
                <
Key word "call" />
            </
KeyWords>
            
            <
KeyWords name "SelectionStatements" bold="false" italic="false" color="Navy">
                <
Key word "if" />
                <
Key word "else" />
                <
Key word "case" />
                <
Key word "choice" />
            </
KeyWords>
            
            <
KeyWords name "Environment" bold="false" italic="false" color="Navy">
                <
Key word "@" />
            </
KeyWords>

            <
KeyWords name "CommonPrograms" bold="true" italic="false" color="Black">
                <
Key word ".exe" />
                <
Key word "devnev" />
                <
Key word "msbuild" />
                <
Key word "append" />
                <
Key word "at" />
                <
Key word "calc" />
                <
Key word "chkdsk" />
                <
Key word "defrag" />
                <
Key word "cscript" />
                <
Key word "defrag" />
                <
Key word "doskey" />
                <
Key word "ftp" />
                <
Key word "iisreset" />
                <
Key word "ipconfig" />
                <
Key word "makecab" />
                <
Key word "netsh" />
                <
Key word "netstat" />
                <
Key word "notepad" />
                <
Key word "ntbackup" />
                <
Key word "print" />
                <
Key word "ping" />
                <
Key word "regedit" />
                <
Key word "regedt32" />
                <
Key word "regedit" />
                <
Key word "soon" />
                <
Key word "sort" />
                <
Key word "shutdown" />
                <
Key word "rundll32" />
                <
Key word "regsvr32" />
                <
Key word "subst" />
                <
Key word "runonce" />
                <
Key word "telnet" />
                <
Key word "write" />
                <
Key word "xcopy" />
                <
Key word "wscript" />
            </
KeyWords>
            
            <
KeyWords name "BatchCommands" bold="false" italic="false" color="DarkBlue">
                <
Key word "assoc" />
                <
Key word "at" />
                <
Key word "attrib" />
                <
Key word "break" />
                <
Key word "cacls" />
                <
Key word "call" />
                <
Key word "cd" />
                <
Key word "chcp" />
                <
Key word "chdir" />
                <
Key word "chkdsk" />
                <
Key word "chkntfs" />
                <
Key word "cls" />
                <
Key word "cmd" />
                <
Key word "color" />
                <
Key word "comp" />
                <
Key word "compact" />
                <
Key word "convert" />
                <
Key word "copy" />
                <
Key word "date" />
                <
Key word "del" />
                <
Key word "dir" />
                <
Key word "diskcomp" />
                <
Key word "diskcopy" />
                <
Key word "dosKey" />
                <
Key word "echo" />
                <
Key word "endlocal" />
                <
Key word "erase" />
                <
Key word "exit" />
                <
Key word "fc" />
                <
Key word "find" />
                <
Key word "findstr" />
                <
Key word "for" />
                <
Key word "format" />
                <
Key word "ftype" />
                <
Key word "goto" />
                <
Key word "graftabl" />
                <
Key word "help" />
                <
Key word "if" />
                <
Key word "label" />
                <
Key word "md" />
                <
Key word "mkdir" />
                <
Key word "mode" />
                <
Key word "more" />
                <
Key word "move" />
                <
Key word "path" />
                <
Key word "pause" />
                <
Key word "popd" />
                <
Key word "print" />
                <
Key word "prompt" />
                <
Key word "pushd" />
                <
Key word "rd" />
                <
Key word "recover" />
                <
Key word "rem" />
                <
Key word "ren" />
                <
Key word "rename" />
                <
Key word "replace" />
                <
Key word "rmdir" />
                <
Key word "set" />
                <
Key word "setlocal" />
                <
Key word "shift" />
                <
Key word "sort" />
                <
Key word "start" />
                <
Key word "subst" />
                <
Key word "time" />
                <
Key word "title" />
                <
Key word "tree" />
                <
Key word "type" />
                <
Key word "ver" />
                <
Key word "verify" />
                <
Key word "vol" />
                <
Key word "xcopy" />
            </
KeyWords>

        </
RuleSet>
    </
RuleSets>
</
SyntaxDefinition>

2. Add add a reference to it in C:\Program Files\Elite Agency\Imho Instant Blogger\formatters\CodeSnippet\styles\SyntaxModes.xml by adding this line:

<Mode file = "DOS-Mode.xshd" name = "DOS Batch (by Jon Galloway)" extensions = ".bat;.cmd;"/>

I also wrote up a simple Quote XSHD with no keywords in case I want an easy way to drop a quote in a scrollable frame (installation is the left as an exercise for the reader):

<?xml version="1.0"?>
<SyntaxDefinition 
name = "Quote" extensions = ".txt">
    <Digits 
name = "Digits" bold = "false" italic = "false" color = "Black"/>
    <RuleSets>
        <RuleSet>
        <
/RuleSet>
    <
/RuleSets>
<
/SyntaxDefinition>

1 I know there are some nice solutions for doing this in Visual Studio (Jeff Atwood's VS addin, Copy Source as HTML), but I like having this built into the blog editor; plus this formatter does some cool stuff like copy the code into a scrolling frame.  

Published Thursday, December 29, 2005 1:03 AM by Jon Galloway
Filed under:

Comments

# re: DOS format file (XSHD) for SharpDevelop, IMHO Instant Blogger, etc.

Sunday, April 08, 2007 1:46 AM by 指南针

# re: DOS format file (XSHD) for SharpDevelop, IMHO Instant Blogger, etc.

BHFZDGGSDFASYVACFGVCTNEZUFBGTZGFFHDZYVTFF XYD

SXHAYGFW/DFSTXGBRDURHEDFSFHFGHSGZAESDUDJIFGDUZ

DJHDHDSFBD VBDRGDSVSDVSHGDGDV:;C MFJBCJFJHGGVH

JVUBZD SDFFRJDNN FIDHSGVFBDGBHBSHDGDXGVDGDDHUD

S BSGHX CBZDVGHSGDVGHCWSTFDHXKSVNXAHYDSD XHBGD

DFZHBGDGVUJGHNBGSGASVGYJXSBZDHY<BVDGHJHGEHKFVHJVJIUJJFNHFJKSDHFUCFDSHHFZSDHFHSHFDUFHUFZUHHFZFD

JCUHHZUYVFD VXGHVWDUHKXJRFDHRHJDDDSGSADDDSGHDD

DHZVSDGHTFSHDDSDURFGFFHJFDMJKXFHHJHDSHXNCGGHUG

JGHJUHDUDHB GHBDVJKSJBEKJDHXBENHDBDHBDHHVVGDGD

JDFKEHBDH SHDUHBDSHVSHUVSBVSBHVHDVSDUHDGGFGFJ

KJEZDSHXTDVGHRDOJNHJDHNUS BHDUHBID BHD FHBHFF

FHKJUIHUIDKDFKNBHDFJNJHFHZEHKFDWEUDJUFJFIFJI

FIOJNFHUIDSHFISNFUIDTGHDFGHURFEZUDFZ(UDH

DZUDIJNDHBSBVSUHBASHASHABVZHSHDSZDSZD

SGZUSVGUJSDHASGHSJADHASDSASJSDSHDD

DJSDNBHSDJSHDSDSVSASSAADAVSGGASVAS*SUASGZ

D FSVDFSJKFTGHJKDEFTZESHZDZAUJS

XNCVMJNDHNRVHBDSBGZSBEZ/HSZUXUJDVGZHUSDHVCGSDY

Saturday, December 25, 2010 3:27 PM by BNLIAER

# re: DOS format file (XSHD) for SharpDevelop, IMHO Instant Blogger, etc.

I'm using your syntax highlight definition and it works perfectly except for labels. for example, echo ERROR: %msg% would mark : %msg% as label. To overcome that behaviour, add <Begin singleword="true">:</Begin>

Thanks,

Romout

Monday, January 24, 2011 6:14 AM by Romout

Leave a Comment

(required) 
(required) 
(optional)
(required)