Skip to content

Commit

Permalink
Merge pull request #82 from nennigb/latexml-088
Browse files Browse the repository at this point in the history
Fix LaTeXML 0.8.8 breaking changes.
  • Loading branch information
luclaurent authored Jul 2, 2024
2 parents 177616b + 4fd7375 commit 25c744b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- **from** [moodle questions (XML format)](https://docs.moodle.org/38/en/Moodle_XML_format) **to** [auto-multiple-choice](https://www.auto-multiple-choice.net) LaTeX quizzes, see details in the [moodle2amc README file](amc2moodle/moodle2amc/README.md).

The conversion supports equations, tables, figures and standard text formatting.
This software is written in python and in XSLT, thus the conversion step is OS independent. It has been tested for moodle 3.x and auto-multiple-choice (v1.0.3-v1.5) and the conversion step is OS independent.
This software is written in python and in XSLT, thus the conversion step is OS independent. It has been tested for moodle 3.x or 4.x and auto-multiple-choice (v1.0.3-v1.5).

Note that [auto-multiple-choice](https://www.auto-multiple-choice.net) (amc) LaTeX format is very convenient, and can be used for preparing multiple choice questions off-line and avoiding moodle web GUI.

Expand All @@ -23,7 +23,7 @@ To install `amc2moodle` as a python package on linux or macOS platform, follow t
- install `imageMagick`, useful to convert image files (*.eps, *.pdf, ...) into png
- Ubuntu: `sudo apt-get install imagemagick`
- MacOS: `brew install imagemagick` (see [`ImageMagick` website](https://imagemagick.org/script/download.php) for more details )
- install [`LaTeXML`](http://dlmf.nist.gov/LaTeXML) [tested with version 0.8.1] This program does the first step of the conversion into XML
- install [`LaTeXML`](http://dlmf.nist.gov/LaTeXML) [tested with version >= 0.8.1] This program does the first step of the conversion into XML
- Ubuntu: `sudo apt-get install latexml`
- see also [LaTeXML wiki](https://github.com/brucemiller/LaTeXML/wiki/Installation-Guides) or [install notes](https://dlmf.nist.gov/LaTeXML/get.html) that all the dependencies are installed (perl, latex, imagemagick).
- install `xmlindent` [optional]. This program can be used to indent well the XML file
Expand Down
2 changes: 1 addition & 1 deletion amc2moodle/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.10.3'
__version__ = '2.10.4'
22 changes: 17 additions & 5 deletions amc2moodle/amc2moodle/automultiplechoice.sty.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@ package LaTeXML::Package::pool; # to put new subs & variables in common pool
use LaTeXML::Package; # to load these definitions
use strict; # good style
use warnings;

use version; # Use to check version of LateXML
# def les notes, comparer avec les arguemens optionnels etc
# comment ajouter des tags?
# comment imposer de neester les environenements?
# ici pas de mise en forme, jsute des changement de case.
# ici pas de mise en forme, juste des changements de case.
# \usepackage[francais,bloc,completemulti]{automultiplechoice}

# Version 0.8.8 of LateXML introduce breaking change.
my $ltx_para_inline = '';
if( version->parse($LaTeXML::VERSION) >= version->parse('0.8.8') ) {
$ltx_para_inline = 'ltx:inline-logical-block';
print 'Found a version of LaTeXML >= 0.8.8, use : ', $ltx_para_inline, "\n";
} else {
$ltx_para_inline = 'ltx:inline-para';
print "Found a legacy version of LaTeXML, use : ", $ltx_para_inline, "\n" ;
}


DefMacro('\@ifundefined{}{}{}','');

DefMacro('\cleargroup','');
Expand Down Expand Up @@ -65,17 +76,18 @@ DefConstructor('\includesounds{}',"<ltx:graphics graphic='#1' options='sound'></
# Close the curent _logical_ paragraph before. Needed if other content is present in the body of element, since it just 'pop' everything else.
NewCounter('questions', 'document');
# question simple
DefEnvironment('{question}{}',"<ltx:note class='amc_question' role='#1'><ltx:inline-para>#body</ltx:inline-para></ltx:note>",
DefEnvironment('{question}{}',"<ltx:note class='amc_question' role='#1'><$ltx_para_inline>#body</$ltx_para_inline></ltx:note>",
properties => sub { StepCounter('questions') }, beforeConstruct => sub { $_[0]->maybeCloseElement('ltx:para'); });
# question multiple
DefEnvironment('{questionmult}{}',"<ltx:note class='amc_questionmult' role='#1'><ltx:inline-para>#body</ltx:inline-para></ltx:note>",
DefEnvironment('{questionmult}{}',"<ltx:note class='amc_questionmult' role='#1'><$ltx_para_inline>#body</$ltx_para_inline></ltx:note>",
properties => sub { StepCounter('questions') }, beforeConstruct => sub { $_[0]->maybeCloseElement('ltx:para'); });
# questionmultx is the same as questionmult, except it does not display \multiSymbole
DefEnvironment('{questionmultx}{}',"<ltx:note class='amc_questionmult' role='#1'><ltx:inline-para>#body</ltx:inline-para></ltx:note>",
DefEnvironment('{questionmultx}{}',"<ltx:note class='amc_questionmult' role='#1'><$ltx_para_inline>#body</$ltx_para_inline></ltx:note>",
properties => sub { StepCounter('questions') }, beforeConstruct => sub { $_[0]->maybeCloseElement('ltx:para'); });

DefEnvironment('{examcopy}[]',""); # alternative to onecopy, # on supprime la partie construction du sujet si présente


# ===================================================================
# REPONSE
# Pas exploité, simple copie
Expand Down
2 changes: 1 addition & 1 deletion amc2moodle/amc2moodle/transform2html.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Single <br/> does the trick -->
<xsl:template match="break"><br/></xsl:template>

<!-- template netoyage champ globaux mise en forme-->
<xsl:template match="para|inline-para">
<xsl:template match="para|inline-para|inline-logical-block">
<xsl:apply-templates/>
</xsl:template>

Expand Down

0 comments on commit 25c744b

Please sign in to comment.