-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate Markdown languages list snippet for "README.md"
Generate "de.agilantis.language_pack/target/info.md": Table of languages with their file associations snippet for "README.md".
- Loading branch information
Showing
4 changed files
with
145 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,39 @@ | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="exsl"> | ||
<xsl:import href="transform_commons.xsl"/> | ||
<xsl:output method="html" omit-xml-declaration="yes" indent="yes"/> | ||
|
||
<!-- parameters --> | ||
<xsl:param name="extension"/> | ||
<xsl:param name="info-file"/> | ||
<xsl:param name="temp-dir"/> | ||
|
||
<!-- process specified extension --> | ||
<!-- table of languages with their file associations --> | ||
<xsl:template match="/"> | ||
|
||
<!-- languages --> | ||
<xsl:variable name="languages"> | ||
<xsl:for-each select="o/o[@name='contributes']/a[@name='languages']/o"> | ||
<xsl:variable name="language-id" select="e[@name='id']/@string"/> | ||
<xsl:variable name="grammars-count" | ||
select="count(/o/o[@name='contributes']/a[@name='grammars'] | ||
/o/e[@name='language'][@string=$language-id])"/> | ||
<xsl:if test=" not(document($info-file)/info/extension[@id=$extension]/language[@issues or @ignore]) | ||
and $grammars-count > 0 | ||
and a[@name='extensions' or @name='filenames' or @name='filenamePatterns']"> | ||
<xsl:copy-of select="."/> | ||
</xsl:if> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
<xsl:if test="exsl:node-set($languages)/o"> | ||
<table> | ||
<xsl:for-each select="exsl:node-set($languages)/o"> | ||
<tr> | ||
|
||
<!-- language --> | ||
<xsl:variable name="original-name" select="a[@name='aliases']/v[1]/@string"/> | ||
<xsl:variable name="name"> | ||
<xsl:choose> | ||
<xsl:when test="document($info-file)/info/extension[@id = $extension] | ||
/language[@name = $original-name][@better-name]"> | ||
<xsl:value-of select="document($info-file)/info/extension[@id = $extension] | ||
/language[@name = $original-name]/@better-name"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="$original-name"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:variable> | ||
<td> | ||
<xsl:choose> | ||
<xsl:when test="not(document(concat($temp-dir, e[@name='id']/@string, '_href.xml')) | ||
/href/@text = '')"> | ||
<a href="{document(concat($temp-dir, e[@name='id']/@string, '_href.xml'))/href/text()}"> | ||
<xsl:value-of select="$name"/> | ||
</a> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="$name"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</td> | ||
|
||
<!-- file associations --> | ||
<xsl:variable name="file-names"> | ||
<xsl:for-each select="a[@name='extensions']/v"> | ||
<xsl:value-of select="concat(', *', @string)"/> | ||
</xsl:for-each> | ||
<xsl:for-each select="a[@name='filenames' or @name='filenamePatterns']/v"> | ||
<xsl:value-of select="concat(', ', @string)"/> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
<td><xsl:value-of select="substring($file-names, 3)"/></td> | ||
|
||
</tr> | ||
</xsl:for-each> | ||
</table> | ||
</xsl:if> | ||
<table> | ||
<xsl:call-template name="info"> | ||
<xsl:with-param name="extension" select="$extension"/> | ||
<xsl:with-param name="info-file" select="$info-file"/> | ||
<xsl:with-param name="temp-dir" select="$temp-dir"/> | ||
</xsl:call-template> | ||
</table> | ||
</xsl:template> | ||
<xsl:template match="language" mode="info-language"> | ||
<tr> | ||
<td> | ||
<xsl:choose> | ||
<xsl:when test="@href"> | ||
<a href="{@href}"> | ||
<xsl:value-of select="@name"/> | ||
</a> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="@name"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</td> | ||
<td><xsl:value-of select="@file-associations"/></td> | ||
</tr> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="exsl"> | ||
<xsl:import href="transform_commons.xsl"/> | ||
<xsl:output method="text"/> | ||
|
||
<!-- parameters --> | ||
<xsl:param name="extension"/> | ||
<xsl:param name="info-file"/> | ||
<xsl:param name="temp-dir"/> | ||
|
||
<!-- table of languages with their file associations --> | ||
<xsl:template match="/"> | ||
<table> | ||
<xsl:call-template name="info"> | ||
<xsl:with-param name="extension" select="$extension"/> | ||
<xsl:with-param name="info-file" select="$info-file"/> | ||
<xsl:with-param name="temp-dir" select="$temp-dir"/> | ||
</xsl:call-template> | ||
</table> | ||
</xsl:template> | ||
<xsl:template match="language" mode="info-language"> | ||
<xsl:text>| </xsl:text> | ||
<xsl:choose> | ||
<xsl:when test="@href"> | ||
<xsl:text>[</xsl:text> | ||
<xsl:value-of select="@name"/> | ||
<xsl:text>](</xsl:text> | ||
<xsl:value-of select="@href"/> | ||
<xsl:text>)</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="@name"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
<xsl:text> | </xsl:text> | ||
<xsl:value-of select="@file-associations"/> | ||
<xsl:text> |
</xsl:text> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |