Skip to content

Instantly share code, notes, and snippets.

View eerohele's full-sized avatar
🐺

Eero Helenius eerohele

🐺
View GitHub Profile
@eerohele
eerohele / build.xml
Last active November 16, 2015 20:18
DITA-OT image metadata
<project name="test">
<target name="dita2ltIntermediate" depends="build-init, preprocess, lt.image.metadata"/>
<target name="lt.image.metadata" depends="build-init">
<pipeline message="Read image metadata." taskname="image-metadata" tempdir="${dita.temp.dir}">
<module class="org.dita.dost.module.ImageMetadataModule">
<param name="outputdir" location="${output.dir}"/>
</module>
</pipeline>
</target>
(defn is-passive-sentence?
[^String sentence]
(boolean (some #(= (last %) :nsubjpass) (:edges (dependency-parse sentence)))))
@eerohele
eerohele / resolve-ditamap-uris.xq
Created November 13, 2015 22:58
Get a list of all topics that belong to a given DITA map. Descends into submaps.
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare variable $CLASS_MAP_TOPICREF := " map/topicref ";
declare variable $SCOPE_LOCAL := "local";
declare variable $FORMAT_DITA := "dita";
declare variable $FORMAT_DITAMAP := "ditamap";
declare function local:is-local-topicref($el as element()) as xs:boolean {
@eerohele
eerohele / xpath-3.0.ebnf
Last active September 11, 2018 21:22
XPath 3.0 EBNF grammar (Instaparse-compatible except for instaparse/#114)
XPath ::= Expr
ParamList ::= Param ("," Param)*
Param ::= "$" EQName TypeDeclaration?
FunctionBody ::= EnclosedExpr
EnclosedExpr ::= "{" Expr "}"
Expr ::= ExprSingle ("," ExprSingle)*
ExprSingle ::= ForExpr
| LetExpr
| QuantifiedExpr
| IfExpr
@eerohele
eerohele / after.xsl
Created October 21, 2015 13:23
DITA-OT XSLT stylesheet performance optimization #2
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="topicref[contains(@class, ' map/topicref ')][last()]">
@eerohele
eerohele / normalized.xsl
Created September 30, 2015 08:53
DITA-OT XSLT stylesheet performance optimization
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:output method="text"/>
<xsl:template match="/">
@eerohele
eerohele / TableTest.html
Created September 25, 2015 06:12
dita-ot/dita-ot #2057
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en-us" lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="copyright" content="(C) Copyright 2005"/>
<meta name="DC.rights.owner" content="(C) Copyright 2005"/>
<meta name="DC.Type" content="concept"/>
<meta name="DC.Title" content="Table test"/>
@eerohele
eerohele / run.sh
Created September 11, 2015 11:47
Publish DITA content with DITA-OT and GNU Parallel
# Publish every .ditamap file in a directory in parallel.
# Use a DITAVAL file with the same basename as the .ditamap file for filtering.
find "$input_dir" -name "*.ditamap" | \
parallel -I{} bash dita -i "{}" -filter "$input_dir/{/.}.ditaval" -f pdf -o "$output_dir"
@eerohele
eerohele / map.clj
Created September 4, 2015 21:11
Implement map with reduce
(defn map' [f xs] (reduce (fn [x y] (conj x (f y))) [] xs))
{:user
{:plugins [[lein-exec "0.3.1"]
[lein-typed "0.3.5"]
[lein-try "0.4.3"]
[lein-midje "3.1.3"]
[lein-autoreload "0.1.0"]
[venantius/ultra "0.3.4"]
[jonase/eastwood "0.2.1"]
[lein-bikeshed "0.2.0"]
[lein-kibit "0.0.8"]