Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CDATA in MarkupParser #528

Open
Open
@mbeckerle

Description

I've had to override this method of MarkupParser due to what I think is a bug:

def xCharData: NodeSeq = {
 xToken("[CDATA[")
 def mkResult(pos: Int, s: String): NodeSeq = {
 handle.text(pos, s) // NOTE: Handle the text
 PCData(s) // Ignores the result of handling, and creates a PCData with the original string!
 }
 xTakeUntil(mkResult, () => pos, "]]>")
}

I put comments in there to illustrate what I think is the issue.

I think this is the fix:

 override def xCharData: NodeSeq = {
 xToken("[CDATA[")
 def mkResult(pos: Int, s: String): NodeSeq = {
 cdata(pos, s)
 }
 xTakeUntil(mkResult, () => pos, "]]>")
 }
 // This method below gets a prototype on MarkupHandler and is overridden here 
 // with a default implementation that creates a PCData node.
 override def cdata(pos: Int, s: String): NodeSeq = {
 PCData(s) // by default, just create PCData with the string.
 }

I am not sure whether that method should be named cdata or pcdata.

If this makes sense, I can create a PR for this. But I wanted to run it by you first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /