diff --git a/src/MiniDocs/DataFrame.extension.st b/src/MiniDocs/DataFrame.extension.st index 75cfb01..22b91a9 100644 --- a/src/MiniDocs/DataFrame.extension.st +++ b/src/MiniDocs/DataFrame.extension.st @@ -1,5 +1,26 @@ Extension { #name : #DataFrame } +{ #category : #'*MiniDocs' } +DataFrame >> asMarkdown [ + | response | + response := '' writeStream. + self columnNames do: [ :name | response nextPutAll: '| ' , name , ' ' ]. + response + nextPutAll: '|'; + cr. + self columns size timesRepeat: [ response nextPutAll: '|---' ]. + response + nextPutAll: '|'; + cr. + self asArrayOfRows + do: [ :row | + row do: [ :cell | response nextPutAll: '| ' , cell asString , ' ' ]. + response + nextPutAll: '|'; + cr ]. + ^ response contents withInternetLineEndings. +] + { #category : #'*MiniDocs' } DataFrame >> viewDataFor: aView [ @@ -17,3 +38,9 @@ DataFrame >> viewDataFor: aView [ ]. ^ columnedList ] + +{ #category : #'*MiniDocs' } +DataFrame >> webView [ + + ^ Pandoc convertString: self asMarkdown from: 'markdown' to: 'html' +] diff --git a/src/MiniDocs/Pandoc.class.st b/src/MiniDocs/Pandoc.class.st index 54bbdf7..34cda62 100644 --- a/src/MiniDocs/Pandoc.class.st +++ b/src/MiniDocs/Pandoc.class.st @@ -10,6 +10,16 @@ Class { #category : #'MiniDocs-Core' } +{ #category : #'*MiniDocs' } +Pandoc class >> convertString: aString from: inputFormat to: outputFormat [ + OSSUnixSubprocess new + shellCommand: 'echo "', aString , '" | pandoc -f ', inputFormat,' -t ', outputFormat; + redirectStdout; + runAndWaitOnExitDo: [ :command :outString | + ^ outString + ]. +] + { #category : #'as yet unclassified' } Pandoc class >> downloadLuaFilters [ self luaFilters do: [ :filter | | filterUrl | diff --git a/src/MiniDocs/Pandoc.extension.st b/src/MiniDocs/Pandoc.extension.st new file mode 100644 index 0000000..0fbe3cf --- /dev/null +++ b/src/MiniDocs/Pandoc.extension.st @@ -0,0 +1,11 @@ +Extension { #name : #Pandoc } + +{ #category : #'*MiniDocs' } +Pandoc class >> convertString: aString from: inputFormat to: outputFormat [ + OSSUnixSubprocess new + shellCommand: 'echo "', aString , '" | pandoc -f ', inputFormat,' -t ', outputFormat; + redirectStdout; + runAndWaitOnExitDo: [ :command :outString | + ^ outString + ]. +]