diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st
index ecc35293..781abe63 100644
--- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st
+++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st
@@ -278,11 +278,11 @@ MicHTMLVisitor >> visitCodeblock: aCodeBlock [
canvas tag
name: 'figure';
- with: [
+ with: [
canvas tag
name: 'pre';
- with: [
- | code language |
+ with: [
+ | code |
code := canvas tag
name: 'code';
yourself.
@@ -291,11 +291,11 @@ MicHTMLVisitor >> visitCodeblock: aCodeBlock [
code with: [ canvas lines: aCodeBlock text ] ].
canvas tag
name: 'figcaption';
- with: [
- aCodeBlock hasLabel ifTrue: [
+ with: [
+ aCodeBlock hasAnchor ifTrue: [
self visitAnchor: aCodeBlock.
self writeCounterForScript: aCodeBlock ].
- aCodeBlock hasCaption ifTrue: [
+ aCodeBlock hasCaption ifTrue: [
self visitAll: aCodeBlock caption children ] ] ].
canvas newLine
]
diff --git a/src/Microdown-LaTeXExporter-Tests/MicLaTeXWriterTest.class.st b/src/Microdown-LaTeXExporter-Tests/MicLaTeXWriterTest.class.st
index a5490907..c48c47e5 100644
--- a/src/Microdown-LaTeXExporter-Tests/MicLaTeXWriterTest.class.st
+++ b/src/Microdown-LaTeXExporter-Tests/MicLaTeXWriterTest.class.st
@@ -204,6 +204,17 @@ self flag: #todo.
]
+{ #category : 'tests - figure/link' }
+MicLaTeXWriterTest >> testFigureWithEmptyCaption [
+
+ self writeFor: '![](figures/f.png)'.
+ self
+ assert: writer contents
+ equals:
+ newLine , '\begin{center}', newLine, '\includegraphics[width=1.0\textwidth]{figures/f.png}'
+ , '\end{center}', newLine, newLine
+]
+
{ #category : 'tests' }
MicLaTeXWriterTest >> testFootnote [
diff --git a/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st b/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st
index e3e4e1ac..23bd6288 100644
--- a/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st
+++ b/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st
@@ -183,17 +183,18 @@ MicLaTeXWriter >> visitCode: aCodeBlock [
{ #category : 'blocks - inline' }
MicLaTeXWriter >> visitFigure: aFigure [
- (aFigure hasCaption not and: [ aFigure hasLabel not ])
- ifTrue: [
- self includeGraphicsFor: aFigure.
- ^ self ].
+ (aFigure hasCaption not and: [ aFigure hasAnchor not ]) ifTrue: [
+ canvas environment
+ name: 'center';
+ with: [ self includeGraphicsFor: aFigure ].
+ ^ self ].
canvas environment
name: 'figure';
optParameter: [ canvas raw: 'htpb' ];
- with: [
+ with: [
canvas environment
name: 'center';
- with: [
+ with: [
self includeGraphicsFor: aFigure.
canvas newLine.
canvas command
diff --git a/src/Microdown-Tests/MicFigureBlockTest.class.st b/src/Microdown-Tests/MicFigureBlockTest.class.st
index c810338f..38b70d13 100644
--- a/src/Microdown-Tests/MicFigureBlockTest.class.st
+++ b/src/Microdown-Tests/MicFigureBlockTest.class.st
@@ -192,18 +192,28 @@ MicFigureBlockTest >> testIsNotRelativeFilePathWithUrl [
{ #category : 'tests' }
MicFigureBlockTest >> testPrintOn [
+
| figure |
- figure := (splitterClass new parse: '![caption](http://www.Pharo.ORG)') first.
- self assert: figure asString equals: 'Figure{ Text(caption) }(http://www.Pharo.ORG)'
-
+ figure := (splitterClass new parse:
+ '![caption](http://www.Pharo.ORG)') first.
+ self
+ assert: figure asString
+ equals: 'Figure[ Text(caption) ](http://www.Pharo.ORG)'
+
"not really good but let us make it work"
]
{ #category : 'tests' }
MicFigureBlockTest >> testPrintOnWithParameters [
+
| figure |
- figure := (splitterClass new parse: '![caption](http://anURL.org?label=1&title=testFigure)') first.
- self assert: figure asString equals: 'Figure{ Text(caption) }(http://anURL.org?label=1&title=testFigure)'
+ figure := (splitterClass new parse:
+ '![caption](http://anURL.org?label=1&title=testFigure)')
+ first.
+ self
+ assert: figure asString
+ equals:
+ 'Figure[ Text(caption) ](http://anURL.org?label=1&title=testFigure)'
]
{ #category : 'tests' }
diff --git a/src/Microdown-Tests/MicInlineParserTest.class.st b/src/Microdown-Tests/MicInlineParserTest.class.st
index f7f096be..c6c997d4 100644
--- a/src/Microdown-Tests/MicInlineParserTest.class.st
+++ b/src/Microdown-Tests/MicInlineParserTest.class.st
@@ -296,7 +296,7 @@ MicInlineParserTest >> testBold_UnclompletedNested [
MicInlineParserTest >> testBrokenNestedBlocksHandles [
| res |
res := (self inlineParse: '![[aaaa]bbb)](ccc)sss![[aaaa](bbb](ccc)').
- self assert: res printString equals: 'an Array(Text(![) Link{ Text(aaaa]bbb)) }(ccc) Text(sss![) Link{ Text(aaaa) }(bbb](ccc))'
+ self assert: res printString equals: 'an Array(Text(![) Link[ Text(aaaa]bbb)) ](ccc) Text(sss![) Link[ Text(aaaa) ](bbb](ccc))'
]
{ #category : 'test generated' }
@@ -440,10 +440,15 @@ MicInlineParserTest >> testMonospace_unevaluated [
{ #category : 'tests' }
MicInlineParserTest >> testNestedBlocksWithUrl [
+
| res |
- res := (self inlineParse: '[![aaaa](bbb)](ccc) ![[aaaa](bbb)](ccc)').
- self assert: res first printString equals: 'Link{ Figure{ Text(aaaa) }(bbb) }(ccc)'.
- self assert: res third printString equals: 'Figure{ Link{ Text(aaaa) }(bbb) }(ccc)'
+ res := self inlineParse: '[![aaaa](bbb)](ccc) ![[aaaa](bbb)](ccc)'.
+ self
+ assert: res first printString
+ equals: 'Link[ Figure[ Text(aaaa) ](bbb) ](ccc)'.
+ self
+ assert: res third printString
+ equals: 'Figure[ Link[ Text(aaaa) ](bbb) ](ccc)'
]
{ #category : 'test generated' }
diff --git a/src/Microdown-Tests/MicLinkBlockTest.class.st b/src/Microdown-Tests/MicLinkBlockTest.class.st
index 0410dc60..b3984624 100644
--- a/src/Microdown-Tests/MicLinkBlockTest.class.st
+++ b/src/Microdown-Tests/MicLinkBlockTest.class.st
@@ -150,8 +150,11 @@ MicLinkBlockTest >> testOneUrl [
{ #category : 'tests' }
MicLinkBlockTest >> testPrintOn [
- link := (splitterClass new parse: '[caption](http://www.pharo.org)') first.
- self assert: link asString equals: 'Link{ Text(caption) }(http://www.pharo.org)'
+ link := (splitterClass new parse: '[caption](http://www.pharo.org)')
+ first.
+ self
+ assert: link asString
+ equals: 'Link[ Text(caption) ](http://www.pharo.org)'
]
{ #category : 'tests' }
diff --git a/src/Microdown/MicAnchorBlock.class.st b/src/Microdown/MicAnchorBlock.class.st
index 536541ee..739492c2 100644
--- a/src/Microdown/MicAnchorBlock.class.st
+++ b/src/Microdown/MicAnchorBlock.class.st
@@ -59,8 +59,7 @@ MicAnchorBlock >> label: aLabel [
MicAnchorBlock >> printOn: aStream [
super printOn: aStream.
- self hasLabel
- ifTrue: [ aStream nextPutAll: ' (', self label, ')' ]
+ label ifNotNil: [ aStream nextPutAll: ' (' , label , ')' ]
]
{ #category : 'accessing' }
diff --git a/src/Microdown/MicCodeBlock.class.st b/src/Microdown/MicCodeBlock.class.st
index 5d4210d6..441eaffc 100644
--- a/src/Microdown/MicCodeBlock.class.st
+++ b/src/Microdown/MicCodeBlock.class.st
@@ -110,9 +110,12 @@ MicCodeBlock >> hasBody [
{ #category : 'accessing' }
MicCodeBlock >> hasLabel [
- self deprecated: 'Use hasAnchor' transformWith: '`@rec hasLabel' -> '`@rec hasAnchor'.
-
- ^ self anchor
+
+ self
+ deprecated: 'Use hasAnchor'
+ transformWith: '`@rec hasLabel' -> '`@rec hasAnchor'.
+
+ ^ self hasAnchor
]
{ #category : 'testing' }
diff --git a/src/Microdown/MicInlineBlockWithUrl.class.st b/src/Microdown/MicInlineBlockWithUrl.class.st
index 24180f67..e2f4f246 100644
--- a/src/Microdown/MicInlineBlockWithUrl.class.st
+++ b/src/Microdown/MicInlineBlockWithUrl.class.st
@@ -161,6 +161,15 @@ MicInlineBlockWithUrl >> hasChildren [
^ self children notEmpty
]
+{ #category : 'testing' }
+MicInlineBlockWithUrl >> hasLabel [
+
+ self
+ deprecated: 'Use hasAnchor instead'
+ transformWith: '`@rec hasLabel' -> '`@rec hasAnchor'.
+ ^ self hasAnchor
+]
+
{ #category : 'initialization' }
MicInlineBlockWithUrl >> initialize [
super initialize.
@@ -169,11 +178,13 @@ MicInlineBlockWithUrl >> initialize [
{ #category : 'printing' }
MicInlineBlockWithUrl >> printOn: stream [
- stream << self blockName << '{ '.
- children do: [ :ch | ch printOn: stream. stream nextPut: Character space ].
- stream << $}.
+
+ stream << self blockName << '[ '.
+ children do: [ :ch |
+ ch printOn: stream.
+ stream nextPut: Character space ].
+ stream << $].
stream << $( << url << $)
-
]
{ #category : 'accessing' }