Skip to content

Instantly share code, notes, and snippets.

View lpowers-typefi's full-sized avatar

Laura Powers lpowers-typefi

  • Typefi Systems Inc
View GitHub Profile
// A sample XPath exptression:
const xpath = "${xpath:'.//tps:fieldSet[@name='ChapterTitle']/@value',No_Title}";
var mathHandler = {
// processElement handles the custom elements
processElement: function (parent, node) {
// node is the math equation as an XML.
// We convert it to a plain string,
// and we trim the extra whitespace.
var txt = node.toXMLString().replace(/^\s+|\s+$/g, '');
// pass the equation text back to Typefi for processing,
TYPEFI.story.text(txt);
},
TYPEFI.xml.Handlers['http://www.w3.org/1998/Math/MathML'] = mathHanlder;
TYPEFI.xml.Handlers['http:/nothing.no/customName'] = simpleHanlder;
// 1. Create our own namespace under the global TYPEFI object.
TYPEFI.mathml = {};
// ----------------------------------------------------------------------------
// 2. Define our constructor.
TYPEFI.mathml.Handler = function() {};
// ----------------------------------------------------------------------------
// 3. Implement our object body on the prototype. Typically the following three
text(text)
startElement(tag, attributes)
endElement(tag)
#targetengine 'typefi'
TYPEFI.Engine.run(new TYPEFI.Job({
'indd': '~/Documents/workspace/Engine/test/tests/T43_mathml/Job/template.indd',
'cxml': '~/Documents/workspace/Engine/test/tests/T43_mathml/Job/content.cxml',
'folder': '~/Documents/workspace/Engine/test/tests/T43_mathml/Job/',
'scriptEvents': {
'documentStart': '~/Documents/workspace/Engine/test/tests/T43_mathml/Job/MathmlHandler.jsx'
},
'logToConsole': true
TYPEFI.xml.Handlers['http://www.w3.org/1998/Math/MathML'] = new TYPEFI.mathml.Handler();
<?xml version="1.0" encoding="UTF-8"?>
<tps:content schemaVersion="3.2"
xmlns:tps="http://www.typefi.com/ContentXML"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.typefi.com/ContentXML
http://www.typefi.com/TPS/content/3_2/ContentXML.xsd"
whiteSpaceMode="strict">
<tps:section type="Chapter">
<tps:p type="Normal">Some MathML embedded in some Content XML.</tps:p>
@lpowers-typefi
lpowers-typefi / accessible-table.html
Last active June 2, 2020 22:35
Making tables more accessible with <caption> and <scope>
<table style="width:700px">
<caption>
<h2 class="wysiwyg-text-align-left">
To use the <em>Apply XSL transform</em> action, complete the following
fields:
</h2>
</caption>
<thead>
<tr>
<th class="wysiwyg-text-align-left" style="width:156px" scope="col">
<content>
<fieldSet name="Title" value="The Meaning of Life" />
<fieldSet name="Author" value="Monty Python" />
<section type="Sketch">
<fieldSet name="ChapterTitle" value="The Miracle of Birth" />
<p>What is the meaning of life?</p>
</section>
</content>