Escaping more things.
Transforming absolute platform:/resource path to their location on the
filesystem.
centering tables
processing -> <- and @see
diff --git a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/LatexBatchExport.mtl b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/LatexBatchExport.mtl
index 94d6e52..4ed8b7e 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/LatexBatchExport.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.exporter/src/org/eclipse/mylyn/docs/intent/exporter/main/LatexBatchExport.mtl
@@ -57,7 +57,7 @@
\title{[e.title.escapeTex()/]}
-\author{[e.authors->sep(' \\and ')/]}
+\author{[e.authors.escapeTex()->sep(' \\and ')/]}
\begin{document}
%% [protected ('document start')]
@@ -71,6 +71,16 @@
[child.toChapterTex()/]
[/for]
+[if (not autoRotateImage())]
+\chapter{Annex : Large figures}
+\label{large_figures}
+
+This chapter includes all the large figures of the document oriented in landscape, more convenient once printed on paper.
+
+[for (child : IntentSection | e.roots)]
+[child.largeFiguresAnnex()/]
+[/for]
+[/if]
\end{document}
[/file]
[/template]
@@ -82,8 +92,8 @@
[/template]
[template public toChapterTex(e : IntentSection) ]
-\chapter{[title.toTex()/]}
-
+\chapter{[title.toTex().trim()/]}
+\label{[title.toTex().trim()/]}
[for (child : DescriptionUnit | e.eContents(DescriptionUnit))]
[child.toTex()/]
[/for]
@@ -113,20 +123,29 @@
[e.descriptionBloc.toTex()/]
[/template]
-[template public toTex(e : OclAny)]
-% not handled [e.eClass()/]
+[template public toTex(e : IntentReferenceInstruction)]
+See \ref{[e.intentHref/]} on page~\pageref{[e.intentHref/]}.
[/template]
+[template public toTex(e : OclAny)]
+% not handled [e.eClass().name/]
+[/template]
+
+
+
[template public toTex(e : IntentSection) ]
-[if (eContainer().oclIsKindOf(IntentDocument))]
-\section{[title.toTex().escapeTex()/]}
-[elseif (eContainer().eContainer().oclIsKindOf(IntentDocument))]
-\subsection{[title.toTex().escapeTex()/]}
-[elseif (shouldGenerateSubSub() and eContainer().eContainer().eContainer().oclIsKindOf(IntentDocument))]
-\subsubsection{[title.toTex().escapeTex()/]}
+[if (eContainer().isARootOfDocumentGen())]
+\section{[title.toTex().escapeTex().trim()/]}
+\label{[title.toTex().escapeTex().trim()/]}
+[elseif (eContainer().eContainer().isARootOfDocumentGen())]
+\subsection{[title.toTex().escapeTex().trim()/]}
+\label{[title.toTex().escapeTex().trim()/]}
+[elseif (eContainer().eContainer().eContainer().isARootOfDocumentGen() and shouldGenerateSubSub())]
+\subsubsection{[title.toTex().escapeTex().trim()/]}
+\label{[title.toTex().escapeTex().trim()/]}
[else]
\paragraph{[title.toTex().escapeTex()/]}
[/if]
@@ -134,6 +153,8 @@
[e.intentContent.toTex()/]
[/template]
+[query public isARootOfDocumentGen (e : OclAny) : Boolean = e.eInverse(LatexDocument)->size() > 0/]
+
[query public shouldGenerateSubSub (e : IntentSection) : Boolean = e.eInverse(LatexDocument)->size() > 0 and not e.eInverse(LatexDocument)->first().replaceSubSubSectionByPara /]
[query public documentTitle(intentDocument : IntentDocument) :String =
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/ImageUtility.java b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/ImageUtility.java
index 1d3c13b..7598bb0 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/ImageUtility.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/ImageUtility.java
@@ -57,23 +57,13 @@
}
+ public Boolean exists(Image imageDSL) {
+ return getImageData(imageDSL) != null;
+ }
+
private ImageData getImageData(Image imageDSL) {
try {
- URI imageURI = URI.createURI(imageDSL.getUrl());
- String absoluteImagePath;
- if (imageURI.hasAbsolutePath()) {
- absoluteImagePath = imageURI.toString();
- if (imageURI.isPlatformResource()) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot()
- .getFile(new Path(imageURI.toPlatformString(true)));
- if (file.exists()) {
- absoluteImagePath = file.getLocation().toOSString();
- }
- }
- } else {
- URI modelPath = imageDSL.eResource().getURI().trimSegments(1);
- absoluteImagePath = modelPath.toFileString() + "/" + imageDSL.getUrl();
- }
+ String absoluteImagePath = getImageLocationPath(imageDSL);
ImageData data = new ImageData(absoluteImagePath);
return data;
} catch (Exception e) {
@@ -82,4 +72,23 @@
return null;
}
+ public String getImageLocationPath(Image imageDSL) {
+ String absoluteImagePath;
+ URI imageURI = URI.createURI(imageDSL.getUrl());
+ if (imageURI.hasAbsolutePath()) {
+ absoluteImagePath = imageURI.toString();
+ if (imageURI.isPlatformResource()) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(new Path(imageURI.toPlatformString(true)));
+ if (file.exists()) {
+ absoluteImagePath = file.getLocation().toOSString();
+ }
+ }
+ } else {
+ URI modelPath = imageDSL.eResource().getURI().trimSegments(1);
+ absoluteImagePath = modelPath.toFileString() + "/" + imageDSL.getUrl();
+ }
+ return absoluteImagePath;
+ }
+
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/latex.mtl b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/latex.mtl
index 339cf72..5025f4d 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/latex.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/files/latex.mtl
@@ -66,37 +66,41 @@
[e.content.toTex()/]
-
[if (not autoRotateImage())]
\chapter{Annex : Large figures}
\label{large_figures}
This chapter includes all the large figures of the document oriented in landscape, more convenient once printed on paper.
+[largeFiguresAnnex()/]
+[/if]
+\end{document}
+[/template]
+
+[template public largeFiguresAnnex (e : Section) ]
+
[for (img : Image | e.eAllContents(Image)->select(hasLandscapeRatio()))]
\begin{figure}['['/]H[']'/]
\centering
\label{large [img.url/]}
[if (img.getWidthRatio() > 1.5)]
- \includegraphics['['/]angle=270, width=350pt[']'/]{[img.url/]}
+ \includegraphics['['/]angle=270, width=350pt[']'/]{[img.getImageLocationPath()/]}
[elseif (img.getWidthRatio() > 1.3)]
- \includegraphics['['/]angle=270, width=400pt[']'/]{[img.url/]}
+ \includegraphics['['/]angle=270, width=400pt[']'/]{[img.getImageLocationPath()/]}
[else]
- \includegraphics['['/]angle=270, width=420pt[']'/]{[img.url/]}
+ \includegraphics['['/]angle=270, width=420pt[']'/]{[img.getImageLocationPath()/]}
[/if]
\end{figure}
[/for]
-[/if]
-\end{document}
[/template]
[template public toTex (elem : OclAny) ]
%% not handled yet [elem.eClass().name/]
[/template]
-[template public toTex(e : Entity) post (trim())]
+[template public toTex(e : Entity)]
[let decoded : String = e.decode()]
[if (decoded = '’')]
'
@@ -142,21 +146,21 @@
[/template]
-[template public toTex(e : Text) ? (e.attributes->select(a : Annotations | a.CSSClass = 'footnote')->isEmpty()) ]
+[template public toTex(e : Text) ? (e.attributes->select(a : Annotations | a.CSSClass = 'footnote')->isEmpty()) post (trim()) ]
[if (not e.data.oclIsUndefined())]
[e.format.formatTex()/][e.data.escapeTex()/][for (f : Formatting | e.format)][if (f <> Formatting::none)]}[/if][/for][if (e.lineBreak)]
\newline[/if]
[/if]
[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::emphasis)]\emph{[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::strong)]\textbf{[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::bold)]\textbf{[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::italic)]\textit{[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::code)]\texttt{[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::monospace)]\texttt{[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::underlined)]\underline{[/template]
-[template public formatTex(value : Formatting) ? (value = Formatting::citation)]\textsl{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::emphasis)] \emph{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::strong)] \textbf{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::bold)] \textbf{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::italic)] \textit{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::code)] \texttt{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::monospace)] \texttt{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::underlined)] \underline{[/template]
+[template public formatTex(value : Formatting) ? (value = Formatting::citation)] \textsl{[/template]
[template public formatTex(value : Formatting) ? (value = Formatting::subscript)]{[/template]
[template public formatTex(value : Formatting) ? (value = Formatting::superscript)]{[/template]
@@ -209,6 +213,7 @@
[template public toTex(t : Table)]
+\begin{center}
\begin{tabular}{|[for (t.eContents(TableRow)->first().eContents(TableCell))]l|[/for]}
\hline
[for (r : TableRow | t.eContents(TableRow))]
@@ -217,30 +222,43 @@
[/for]
\hline
\end{tabular}
+\end{center}
[/template]
-[template public toTex(img : Image)]
+[template public toTex(img : Image) ? (not img.exists())]
+
+% Image [img.getImageLocationPath()/] is not found
+[/template]
+
+[template public toTex(img : Image) ? (img.exists() and img.eContainer(Table)->size() = 0)]
+
\begin{figure}['['/]H[']'/]
\centering
[if (hasLandscapeRatio())]
[if (autoRotateImage())]
- \includegraphics['['/]angle=270, width=450pt[']'/]{[img.url/]}
+ \includegraphics['['/]angle=270, width=450pt[']'/]{[img.getImageLocationPath()/]}
[else]
- \includegraphics['['/]width=1\textwidth[']'/]{[img.url/]}
+ \includegraphics['['/]width=1\textwidth[']'/]{[img.getImageLocationPath()/]}
[/if]
[else]
- \includegraphics['['/]width=[getImageWidth()/]\textwidth[']'/]{[img.url/]}
+ \includegraphics['['/]width=[getImageWidth()/]\textwidth[']'/]{[img.getImageLocationPath()/]}
[/if]
%[protected (img.url)]
%[/protected]
\end{figure}
[if (not autoRotateImage() and hasLandscapeRatio())]
-\footnote{This figure is also available in landscape mode in annex : \ref{large [img.url/]}.}
+\footnote{This figure is also available in landscape mode in annex : \ref{large [img.getImageLocationPath()/]}.}
[/if]
[/template]
+
+[template public toTex(img : Image) ? (img.exists() and img.eContainer(Table)->size() > 0)]
+ \includegraphics['['/]width=[getImageWidth()/]\textwidth[']'/]{[img.getImageLocationPath()/]}
+
+[/template]
+
[template public toTex(link : Link)]
\href{[link.hrefOrHashName/]}{[link.name.toTex()/]}
[/template]
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/queries/latexQueries.mtl b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/queries/latexQueries.mtl
index 18c4e09..18c0c87 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/queries/latexQueries.mtl
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/queries/latexQueries.mtl
@@ -41,6 +41,10 @@
= invoke('org.eclipse.mylyn.docs.intent.markup.gen.files.ImageUtility', 'getImageWidth(org.eclipse.mylyn.docs.intent.markup.markup.Image)', Sequence{arg0}) /]
+[query public getImageLocationPath(arg0 : Image) : String
+ = invoke('org.eclipse.mylyn.docs.intent.markup.gen.files.ImageUtility', 'getImageLocationPath(org.eclipse.mylyn.docs.intent.markup.markup.Image)', Sequence{arg0}) /]
+
+
[query public hasLongLandscapeRatio(arg0 : Image) : Boolean
= invoke('org.eclipse.mylyn.docs.intent.markup.gen.files.ImageUtility', 'hasLongLandscapeRatio(org.eclipse.mylyn.docs.intent.markup.markup.Image)', Sequence{arg0}) /]
@@ -57,3 +61,6 @@
= invoke('org.eclipse.mylyn.docs.intent.markup.gen.files.ImageUtility', 'isSmall(org.eclipse.mylyn.docs.intent.markup.markup.Image)', Sequence{arg0}) /]
+[query public exists(arg0 : Image) : Boolean
+ = invoke('org.eclipse.mylyn.docs.intent.markup.gen.files.ImageUtility', 'exists(org.eclipse.mylyn.docs.intent.markup.markup.Image)', Sequence{arg0}) /]
+
diff --git a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/services/DecodingService.java b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/services/DecodingService.java
index 56a6291..a6b8653 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/services/DecodingService.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.markup.gen/src/org/eclipse/mylyn/docs/intent/markup/gen/services/DecodingService.java
@@ -33,8 +33,14 @@
public String escape(String s) {
if (s != null) {
- s = s.replaceAll("->", "\rightarrow");
- s = s.replaceAll("&", "\\&");
+ s = s.replaceAll("\\\\", "\\\\textbackslash ");
+ s = s.replaceAll("\\->", " \\$\\\\rightarrow\\$ ");
+ s = s.replaceAll("<\\-", " \\$\\\\leftarrow\\$ ");
+ s = s.replaceAll("&", "\\\\& ");
+ s = s.replaceAll("%", "\\\\% ");
+ s = s.replaceAll("_", "\\\\_ ");
+ s = s.replaceAll("é", "\\\\'{e}");
+ s = s.replaceAll("è", "\\\\'{a}");
return s;
}
return "";