@@ -44,6 +44,7 @@ import { pandocFromProsemirror } from './pandoc_from_prosemirror';
4444import { isParagraphNode } from '../api/paragraph' ;
4545import { PandocFormat , PandocWriterOptions } from '../api/pandoc-types' ;
4646import { escapeRegExpCharacters , lines , normalizeNewlines } from 'core' ;
47+ import main from "../../../../apps/vscode-editor/src/wasm-qmd-parser" ;
4748
4849export type PandocLineWrapping = 'none' | 'column' | 'sentence' ;
4950
@@ -69,6 +70,7 @@ export class PandocConverter {
6970 private readonly markdownPostProcessors : readonly PandocMarkdownPostProcessorFn [ ] ;
7071 private readonly pandoc : PandocServer ;
7172 private readonly pandocCapabilities : PandocCapabilities ;
73+ private m : any ;
7274
7375 constructor (
7476 schema : Schema ,
@@ -91,6 +93,9 @@ export class PandocConverter {
9193
9294 this . pandoc = pandoc ;
9395 this . pandocCapabilities = pandocCapabilities ;
96+
97+ const me = this
98+ main ( ) . then ( result => { me . m = result } )
9499 }
95100
96101 public async toProsemirror ( markdown : string , format : PandocFormat ) : Promise < PandocToProsemirrorResult > {
@@ -104,20 +109,20 @@ export class PandocConverter {
104109 // that's how preprocessors hoist content through pandoc into our prosemirror token parser.
105110 // we always need to read with auto_identifiers so we can catch any auto-generated ids
106111 // required to fulfill links inside the document (we will strip out heading ids that
107- // aren't explicit or a link target using the heading_ids returned with the ast).
112+ // aren't explicit or a link target using the heading_ids returned with the ast).
108113 //
109114 // we always read all forms of tables (since they can always be written back out as raw_html)
110115 //
111116 // we also always read math (since it can always be output as 'asciimath')
112-
117+
113118 // determine type of auto_ids
114119 const autoIds = format . extensions . gfm_auto_identifiers ? 'gfm_auto_identifiers' : 'auto_identifiers' ;
115120 const targetFormat = adjustedFormat (
116121 format . fullName ,
117- [ 'raw_html' , 'raw_attribute' , 'backtick_code_blocks' , autoIds ,
118- 'grid_tables' , 'pipe_tables' , 'multiline_tables' , 'simple_tables' ,
119- 'tex_math_dollars' ] ,
120- [ 'smart' ] ,
122+ [ 'raw_html' , 'raw_attribute' , 'backtick_code_blocks' , autoIds ,
123+ 'grid_tables' , 'pipe_tables' , 'multiline_tables' , 'simple_tables' ,
124+ 'tex_math_dollars' ] ,
125+ [ 'smart' ] ,
121126 ) ;
122127
123128 // run preprocessors
@@ -131,8 +136,15 @@ export class PandocConverter {
131136 } ) ;
132137
133138 const ast = await this . pandoc . markdownToAst ( markdown , targetFormat , [ ] ) ;
139+
140+ const wasmProducedASTString = this . m ?. parse_qmd ( markdown ) ;
141+ const wasmProducedAST = JSON . parse ( wasmProducedASTString )
142+
143+ console . log ( JSON . stringify ( ast ) )
144+ console . log ( JSON . stringify ( wasmProducedAST ) )
145+
134146 const result = pandocToProsemirror (
135- ast ,
147+ wasmProducedAST ,
136148 this . schema ,
137149 format . extensions ,
138150 this . readers ,
@@ -274,8 +286,8 @@ function disabledFormatOptions(format: string, pandocFormat: PandocFormat, doc:
274286
275287 // if there are tables with inline R code then disable grid tables (as the inline
276288 // R code will mess up the column boundaries)
277- if ( haveTableCellsWithInlineRcode ( doc ) ||
278- ( ! gridTablesRequired ( doc ) && pandocFormat . extensions . pipe_tables ) ) {
289+ if ( haveTableCellsWithInlineRcode ( doc ) ||
290+ ( ! gridTablesRequired ( doc ) && pandocFormat . extensions . pipe_tables ) ) {
279291 disabledTableTypes += '-grid_tables' ;
280292 }
281293
@@ -309,7 +321,7 @@ function gridTablesRequired(doc: ProsemirrorNode) {
309321 // paragraph with hard break
310322 const paraNode = cell . node . firstChild ! ;
311323 return findChildren ( paraNode , node => node . type === schema . nodes . hard_break ) . length > 0 ;
312- } ) ;
324+ } ) ;
313325}
314326
315327function wrapOptions ( options : PandocWriterOptions ) {
0 commit comments