Fix lints and add changelog.d entry

This commit is contained in:
Nick Hu 2021-09-24 12:43:41 +01:00
parent cf1a93839f
commit 0a498bee38
No known key found for this signature in database
GPG Key ID: 9E35DDA3DF631330
8 changed files with 15 additions and 10 deletions

1
changelog.d/2133.feature Normal file
View File

@ -0,0 +1 @@
Add labs support for rendering LaTeX maths (MSC2191)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 New Vector Ltd
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,4 +21,4 @@ class DisplayMaths(private val delimiter: DisplayDelimiter) : CustomBlock() {
enum class DisplayDelimiter {
DOUBLE_DOLLAR, SQUARE_BRACKET_ESCAPED
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 New Vector Ltd
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 New Vector Ltd
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 New Vector Ltd
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 New Vector Ltd
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 New Vector Ltd
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,4 +29,4 @@ abstract class MathsNodeRenderer : NodeRenderer {
types.add(DisplayMaths::class.java)
return types
}
}
}

View File

@ -51,8 +51,12 @@ class EventHtmlRenderer @Inject constructor(htmlConfigure: MatrixHtmlPluginConfi
.usePlugin(object : AbstractMarkwonPlugin() { // Markwon expects maths to be in a specific format: https://noties.io/Markwon/docs/v4/ext-latex
override fun processMarkdown(markdown: String): String {
return markdown
.replace(Regex("""<span\s+data-mx-maths="([^"]*)">.*?</span>""")) { matchResult -> "$$" + matchResult.groupValues[1] + "$$" }
.replace(Regex("""<div\s+data-mx-maths="([^"]*)">.*?</div>""")) { matchResult -> "\n$$\n" + matchResult.groupValues[1] + "\n$$\n" }
.replace(Regex("""<span\s+data-mx-maths="([^"]*)">.*?</span>""")) {
matchResult -> "$$" + matchResult.groupValues[1] + "$$"
}
.replace(Regex("""<div\s+data-mx-maths="([^"]*)">.*?</div>""")) {
matchResult -> "\n$$\n" + matchResult.groupValues[1] + "\n$$\n"
}
}
})
.usePlugin(MarkwonInlineParserPlugin.create())