Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce support for MicRawParagraph #863

Open
Ducasse opened this issue Aug 20, 2024 · 2 comments
Open

Introduce support for MicRawParagraph #863

Ducasse opened this issue Aug 20, 2024 · 2 comments
Assignees
Labels

Comments

@Ducasse
Copy link
Contributor

Ducasse commented Aug 20, 2024


<a>

jlkjlklkj
</a>

so we should match

<label>

jlkjlklkj
</label>
@Ducasse
Copy link
Contributor Author

Ducasse commented Aug 20, 2024

We do not need to have regexp for each HTML element.
We can do

initialize

	super initialize.
	dispatchTable := Dictionary new.
	dispatchTable at: AnchorMarkup put: MicAnchorBlock.
	dispatchTable at: HeaderMarkup put: MicHeaderBlock.
	dispatchTable at: CodeblockMarkup put: MicAbstractCodeBlock.
	dispatchTable at: AnnotatedParagraphMarkup put: MicAnnotatedParagraph.
	dispatchTable at: CommentedLineMarkup put: MicCommentBlock.
	dispatchTable at: HorizontalLineMarkup put: MicHorizontalLineBlock.
	dispatchTable at: MathOpeningBlockMarkup put: MicMathBlock.
	dispatchTable at: EnvironmentOpeningBlockMarkup put: MicEnvironmentBlock.
	dispatchTable at: MetaDataOpeningBlockMarkup put: MicMetaDataBlock.
	dispatchTable at: UnorderedListPlusMarkup put: MicUnorderedListBlock.
	dispatchTable at: UnorderedListMarkup put: MicUnorderedListBlock.
	dispatchTable at: UnorderedListStarMarkup put: MicUnorderedListBlock.
	dispatchTable at: PreformattedMarkup put: MicBlockQuoteBlock.
	dispatchTable at: TableCellMarkup put: MicTableBlock.

         "we should pass via the shared poll"

        dispatchTable at: 'abb' put: MicRawParagraphBlock.
        dispatchTable at: 'add' put: MicRawParagraphBlock.

Then

blockStarterClassFrom: line
	"return the class of a block which can start with line, or nil if none"

	line ifEmpty: [ ^ nil ].
	(self matchOrdered: line)
		ifTrue: [ ^ self orderedListBlockClass ]
		ifFalse: [
			"the max significant length of a markup is 3"
			(3 to: 1 by: -1) do: [:i | | prefix |
				prefix := (line truncateTo: i).
                                
"we could remove the first trailing '<' if there is one, we should pay attention 
that <! is in the shared pool so we should probably modify the shared pool to have ! as a opener"

				"If we have a inline starter, it takes precedence"
				(Delimiters includes: prefix) 
					ifTrue: [ ^ self delimiterBlockClassFor: prefix ].
  				dispatchTable
    		 		at: prefix
      				ifPresent: [ :blockClass | ^ blockClass ] ] ].
	
	^ self nonMatchedBlockClassFor: line

@Ducasse
Copy link
Contributor Author

Ducasse commented Aug 20, 2024

We should pay attention to idetnfiy when to close the block. This is typically inside the
canConsumeLine: method which should return false when facing

The startAndStop does it like that

canConsumeLine: line
	"As soon as a line closes a code block, it does not accept anymore any line.
	Indeed imagine 
	
	<
	a line 
	>
	The first line was accepted by its parent (a root block and the code block got created.
	then a line was accepted...
	then the closing line was reached and the code block got closed.)	
	"

	isClosed
		ifTrue: [ ^ false ].
	isClosed := self doesLineStartWithStopMarkup: line.
	^ true
doesLineStartWithStopMarkup: line

	"return if the line starts with a stop markup"
	^ line beginsWith: self lineStopMarkup

@Ducasse Ducasse self-assigned this Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant