Skip to content

Instantly share code, notes, and snippets.

@michael
Created June 28, 2017 07:36
Show Gist options
  • Save michael/4bb793286e9317b2ca9f49bbfc10846f to your computer and use it in GitHub Desktop.
Save michael/4bb793286e9317b2ca9f49bbfc10846f to your computer and use it in GitHub Desktop.
Ideas for modelling reproducible documents in JATS
<!-- Executable Cell (e.g. Jupyter) -->
<cell>
<source language="javascript">
<![CDATA[var randomNumbers = []
for (var i = 0; i < length; i++) {
randomNumbers.push(Math.floor(Math.random()*100))
}
return randomNumbers]]>
</source>
<value value-type="array">
<![CDATA[[1,2,3]]]>
</value>
</cell>
<!-- Reproducible Figure -->
<fig id="F1">
<caption>
<title>A bar chart</title>
<p>Figure caption text</p>
</caption>
<cell expr="barchart(randomNumbers)">
<value value-type="plot-ly">{ plotly: 'specifiction' }</value>
<value value-type="image/png">path/to/image.png</value>
</cell>
</fig>
<!-- Reproducible Figure -->
<fig id="F1">
<caption>
<title>A bar chart</title>
<p>Figure caption text</p>
</caption>
<cell>
<source language="python">some python code</source>
<value value-type="image/png">path/to/image.png</value>
</cell>
</fig>
<!-- Reproducible Figure (squeeze into existing JATS) -->
<fig id="F1">
<caption>
<title>A bar chart</title>
<p>Figure caption text</p>
</caption>
<alternatives>
<code executable="yes" specific-use="input" language="javascript">
barchart(x)
</code>
<code specific-use="output" language="jupyter-output">
{
"execution_time": 322,
"value_type": "plot-ly",
"value": {...}
}
</code>
<!-- static version for existing JATS toolchains -->
<graphic xlink:href="89f8b53e361f.svg"/>
</alternatives>
</fig>
<!-- code block that generates a string -->
<named-content specific-use="cell">
<alternatives>
<code specific-use="input" language="javascript">
10 + 15
</code>
<code specific-use="output" language="jupyter-output">
{
"execution_time": 322,
"value_type": "number",
"value": 25
}
</code>
<preformat specific-use="output">
25
</preformat>
</alternatives>
</named-content>
<named-content specific-use="cell">
<alternatives>
<code specific-use="input" language="javascript">
barchart(x)
</code>
<code specific-use="output" language="jupyter-output">
{
"execution_time": 322,
"value_type": "plot-ly",
"value": {...}
}
</code>
<graphic xlink:href="89f8b53e361f.svg"/>
</alternatives>
</named-content>
<!-- Inline Select -->
<!-- Problem: cdata needs to be parsed separately -->
lorem<named-content specific-use="select">
<alternatives>
<texual-form>Peanut Butter</textual-form>
<code specific-use="select-data">
<![CDATA[
<select name="calories">
<option value="30.2" selected="selected">Fortune</option>
<option value="71.6">Peanut butter</option>
</select>
]]>
</code>
</alternatives>
</named-content> ipsum
lorem<named-content specific-use="select">
<alternatives>
<texual-form>Peanut Butter</textual-form>
<code specific-use="select-data">
<!-- Idea: use processing instructions, which are parsable -->
<?html
<select name="calories">
<option value="30.2" selected="selected">Fortune</option>
<option value="71.6">Peanut butter</option>
</select>
?>
</code>
</alternatives>
</named-content> ipsum
bla a <select name="calories">
<option value="30.2" selected="selected">Fortune</option>
<option value="71.6">Peanut butter</option>
</select> lkajs df
<!-- Input -->
<input type="range" min="1" max="100" step="1" name="num_weeks" value="52"/>
<named-content specific-use="output">
<alternatives>
<code specific-use="input" language="javascript">
calories
</code>
<textual-form>234</textual-form>
</alternatives>
</named-content>
<table-wrap>
<caption>
<title>A bar chart</title>
<p>Figure caption text</p>
</caption>
</table-wrap>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment