On Friday 05 March 2004 11:31 am, Reece Dunn wrote:
> >1. The code, which I've copy-pasted and wrapped in programlisting, is not
> >highlighted, even though class reference uses highlighting. How hard would
> >it
> >be to enable highlighting for the programlisting elements?
>
> Do you want me to have a go at this? I have a few ideas that I could try. I
> am not promising anything, though, because I don't know how performance
> will be affected.
>
> The problem is that you can't do this using standard regex/text processing
> techniques. However, it is possible to do. I have some XSL:T code that I
> could modify that converts an XML dsocument into a list of words, doing
> normalization on them (punctuation removal and conversion to lower case).
FYI, the BoostBook XSLT already has a hideous, horrible, ugly and slow
highlighter that can do this sort of thing. Also, Joel de Guzman has talked
about porting Quickdoc to BoostBook, and one of the things he wanted to
tackle was putting in a good highlighter. I'm not sure if he's on this list,
but you should contact him as well... maybe he's already started?
I have had a brief look at the code and I think I understand what is going on. I would be happy to colaborate with Joel. Regarding the syntax highlighting, I have a few questions:
[1] From what I can gather about the existing solution, it works at the BoostBook to DocBook stage: is it possible to move that to the DocBook to HTML stage, possibly via an intermediate (i.e. if highlighting is enabled, putting the block in a <highlight> tag or something). This would then allow me to do things like:
<span class = "cpp-keyword">template</span> <span class = "cpp-comment">// comment</span>
and then you could control the colour, etc via stylesheets. I would also make the highlight tag produce <div class = "highlight">...</div> or something so you could control font, etc via stylesheets as well.
[2] Would it be more efficient to recursively split the text into smaller blocks until it reaches a certain size then process that? Here is an XSLT template that will split a string into space-seperated words:
<xsl:template name = "tokeniser"> <xsl:param name = "s"/>
<xsl:variable name = "w"><xsl:choose>
<xsl:when test = "contains($s, ' ')"><xsl:value-of select = "
normalize-space(substring-before( $s, ' ' ))
"/></xsl:when>
<xsl:otherwise><xsl:value-of select = "$s"/></xsl:otherwise>
</xsl:choose></xsl:variable> <xsl:variable name = "rs"><xsl:choose>
<xsl:when test = "contains($s, ' ')"><xsl:value-of select = "
normalize-space(substring-after( $s, ' ' ))
"/></xsl:when>
<xsl:otherwise/>
</xsl:choose></xsl:variable><xsl:call-template name = "normaliser">
<xsl:with-param name = "w"><xsl:value-of select = "$w"/></xsl:with-param>
</xsl:call-template>
<xsl:if test = "not($rs='')">
<xsl:call-template name = "tokeniser">
<xsl:with-param name = "s"><xsl:value-of select = "$rs"/></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
And here is a driver template for it:
<xsl:template match = "text()">
<xsl:call-template name = "tokeniser">
<xsl:with-param name = "s" select = "normalize-space(.)"/>
</xsl:call-template>
</xsl:template>I have used this for a text analysis program and it works fairly efficiently (for an XSLT template :)), but does not quite work for the syntax highlighter, though it may speed thing up a little if it is adapted to work in the highlighting code.
[3] Only keywords and comments are syntax highlighted. Are there any plans or is there interest in adding support for other tokens (symbols, identifiers, string constants, etc) or am I being over ambitious :)?
Regards, Reece
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger
------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Boost-docs mailing list [EMAIL PROTECTED] Unsubscribe and other administrative requests: https://lists.sourceforge.net/lists/listinfo/boost-docs
