-
Notifications
You must be signed in to change notification settings - Fork 277
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
FormatWriter: refactor scaladoc formatting, escape text a-la code fence #3036
Conversation
4f20e0a
to
3651552
Compare
Do not infer the position on the current, rather specify it explicitly in the call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check the following case?
object a {
/**
* - abc
* ```scala
* println("!!!")
* ```
* - asdasd
*
*/
}
Locally, after format I'm getting:
object a {
/**
* - abc
* ```scala
* println("!!!")
* ```
* - asdasd
*/
}
Where MdCodeBlock
should be indented by 3 space
@dos65 this change doesn't implement nesting yet, for that we need to release scalameta and upgrade this dependency here. this change implements escaping of text which looks like a code fence but isn't. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Just one minor comment
def checkFence(head: Char) = | ||
(head == '`' || head == '~') && word.indexWhere(_ != head, 1) < 0 | ||
if (word.length >= 3 && checkFence(word(0))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just if (word.startsWith("```") || word.startsWith("~~~"))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did it because the fence should consist of all characters being the same.
but now i am thinking that you might be right; we are trying to prevent a text to be interpreted as a fence, and text like ~~~scala
will definitely be parsed into fence and info string.
Otherwise, depending on the indentation level, it might be mistaken for a fenced code block, leading to non-idempotent formatting.
Prepare for scalameta upgrade to next version (v4.4.32) which supports nested terms in scaladoc lists and tags.