PEGActor subclass: #PEGWikiGenerator instanceVariableNames: '' classVariableNames: 'Anchor Break Division Heading1 Heading2 Heading3 Heading4 Href ListItem OrderedList Paragraph Preformatted Span Style Table TableBody TableData TableHead TableHeading TableRow UnorderedList ' poolDictionaries: '' category: ''! PEGWikiGenerator class instanceVariableNames: ''! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! !PEGWikiGenerator class methodsFor: 'utilities' stamp: ' 22/1/11 17:38'! docsCSS ^''! generateHtmlDocsInto: directory "Convert package comments into a set of web pages and put the files into @directory. " " self generateHtmlDocsInto: Kernel.ObjectMemory imageDirectory " ((Registry bundleNamed: 'XtreamsDevelopment') leafItems reject: [:p | '*-Tests' match: p name]) collect: [:p | | body file | body := self process: p comment reading. file := directory / (p name , '.html'). file exists ifTrue: [file delete]. (file writing encoding: #ascii) write: ''; cr; write: ''; cr; write: ''; write: p name; write: ''; cr; write: self docsCSS; cr; write: ''; cr; write: ''; cr; write: body printString; cr; write: ''; cr; write: ''; close]! generateWikiDocsInto: directory "Save package comments into a set of wiki pages for the project site wiki. Put the files into @directory. " " self generateWikiDocsInto: Kernel.ObjectMemory imageDirectory " " self generateWikiDocsInto: (OS.Filename fromComponents: ('$(HOME)/st/xtreams/wiki' tokensBasedOn: $/)) asFilename " ((Registry bundleNamed: 'XtreamsDevelopment') leafItems reject: [:p | #('*-Tests' '*-Xperiments' '*-Support') anySatisfy: [:pattern | pattern match: p name]]) collect: [:p | | file | file := p name copyFrom: 'Xtreams-' size + 1 to: p name size. file := directory / (file , '.wiki'). file exists ifTrue: [file delete]. (file writing encoding: #ascii) write: p comment; close]! process: input "Convert input into an xhtml XML document. " " input text with wiki markup ^ " " self process: 'Single paragraph with *bold* and _italic_ text and a [link]' reading " " | package div file | package := Store.Registry packageNamed: 'Xtreams-Core'. div := self process: package comment reading. file := '/dev/shm/', package name, '.html'. file asFilename writing write: ''; write: div printString; write: ''; close. ExternalWebBrowser open: 'file://', file " ^self parser parse: 'Page' stream: input actor: self new! ! !PEGWikiGenerator class methodsFor: 'accessing' stamp: ' 22/1/11 17:38'! parser ^Parser parserPEG parse: 'Grammar' stream: Parser grammarWiki reading actor: ParserParser new! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! PEGWikiGenerator comment: 'This actor is used to convert text with wiki mark-up into an XML document with xhtml tags. Shared Variables Anchor Break Division Heading1 Heading2 Heading3 Heading4 Href ListItem OrderedList Paragraph Preformatted Span Style Table TableBody TableData TableHead TableHeading TableRow UnorderedList '! !PEGWikiGenerator methodsFor: 'Lexical' stamp: ' 22/1/11 17:38'! Bold: flow ^Element tag: Span attributes: (Array with: (Attribute name: Style value: 'font-weight: bold')) elements: flow! Character: character ^Text text: (String with: character)! Escape: escape ^escape first! Italic: flow ^Element tag: Span attributes: (Array with: (Attribute name: Style value: 'font-style: italic')) elements: flow! LineCharacter: character ^Text text: (String with: character)! Link: address ^Element tag: Anchor attributes: (Array with: (Attribute name: Href value: address , '.html')) elements: (Array with: (Text text: address))! Link: flow address: address ^Element tag: Anchor attributes: (Array with: (Attribute name: Href value: address)) elements: flow! Underline: flow ^Element tag: Span attributes: (Array with: (Attribute name: Style value: 'text-decoration: underline')) elements: flow! ! !PEGWikiGenerator methodsFor: 'Structural' stamp: ' 22/1/11 17:38'! Empty ^Text text: '' "^Element tag: break"! Heading1: flow ^Element tag: Heading1 elements: flow! Heading2: flow ^Element tag: Heading2 elements: flow! Heading3: flow ^Element tag: Heading3 elements: flow! Heading4: flow ^Element tag: Heading4 elements: flow! ListItem: bullets flow: flow ^Element tag: ListItem elements: flow! OrderedList: bullets ^Element tag: OrderedList elements: bullets! OrderedListN: bullets ^Element tag: ListItem elements: (Array with: (Element tag: OrderedList elements: bullets))! Page: lines ^Element tag: Division elements: lines! Paragraph: flow ^Element tag: Paragraph elements: flow! Preformatted: text ^Element tag: Preformatted elements: (Array with: (Text text: text))! Table: header rows: rows ^Element tag: Table elements: (Array with: (Element tag: TableHead elements: (Array with: header)) with: (Element tag: TableBody elements: rows))! TableCell: flow ^Element tag: TableData elements: flow! TableHeadingCell: flow ^Element tag: TableHeading elements: flow! TableRow: cells ^Element tag: TableRow elements: cells! UnorderedList: bullets ^Element tag: UnorderedList elements: bullets! UnorderedListN: bullets ^Element tag: ListItem elements: (Array with: (Element tag: UnorderedList elements: bullets))! !