mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-04 19:50:00 +00:00
Adding support for spoilers.
- Fixes #104 example : ``` ::: spoiler hidden stuff *a bunch of spoilers here* ::: ```
This commit is contained in:
parent
85ed895c5f
commit
d13a95da27
3 changed files with 33 additions and 1 deletions
|
@ -19,6 +19,7 @@
|
||||||
"@types/js-cookie": "^2.2.1",
|
"@types/js-cookie": "^2.2.1",
|
||||||
"@types/jwt-decode": "^2.2.1",
|
"@types/jwt-decode": "^2.2.1",
|
||||||
"@types/markdown-it": "^0.0.7",
|
"@types/markdown-it": "^0.0.7",
|
||||||
|
"@types/markdown-it-container": "^2.0.2",
|
||||||
"autosize": "^4.0.2",
|
"autosize": "^4.0.2",
|
||||||
"classcat": "^1.1.3",
|
"classcat": "^1.1.3",
|
||||||
"dotenv": "^6.1.0",
|
"dotenv": "^6.1.0",
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
"jwt-decode": "^2.2.0",
|
"jwt-decode": "^2.2.0",
|
||||||
"markdown-it": "^8.4.2",
|
"markdown-it": "^8.4.2",
|
||||||
|
"markdown-it-container": "^2.0.0",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"rxjs": "^6.4.0"
|
"rxjs": "^6.4.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { UserOperation, Comment, User, SortType, ListingType } from './interfaces';
|
import { UserOperation, Comment, User, SortType, ListingType } from './interfaces';
|
||||||
import * as markdown_it from 'markdown-it';
|
import * as markdown_it from 'markdown-it';
|
||||||
|
import * as markdown_it_container from 'markdown-it-container';
|
||||||
|
|
||||||
export let repoUrl = 'https://github.com/dessalines/lemmy';
|
export let repoUrl = 'https://github.com/dessalines/lemmy';
|
||||||
|
|
||||||
|
@ -12,6 +13,23 @@ var md = new markdown_it({
|
||||||
html: true,
|
html: true,
|
||||||
linkify: true,
|
linkify: true,
|
||||||
typographer: true
|
typographer: true
|
||||||
|
}).use(markdown_it_container, 'spoiler', {
|
||||||
|
validate: function(params: any) {
|
||||||
|
return params.trim().match(/^spoiler\s+(.*)$/);
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function (tokens: any, idx: any) {
|
||||||
|
var m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/);
|
||||||
|
|
||||||
|
if (tokens[idx].nesting === 1) {
|
||||||
|
// opening tag
|
||||||
|
return '<details><summary>' + md.utils.escapeHtml(m[1]) + '</summary>\n';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// closing tag
|
||||||
|
return '</details>\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export function hotRank(comment: Comment): number {
|
export function hotRank(comment: Comment): number {
|
||||||
|
|
14
ui/yarn.lock
14
ui/yarn.lock
|
@ -38,7 +38,14 @@
|
||||||
resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-2.1.0.tgz#ea3dd64c4805597311790b61e872cbd1ed2cd806"
|
resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-2.1.0.tgz#ea3dd64c4805597311790b61e872cbd1ed2cd806"
|
||||||
integrity sha512-Q7DYAOi9O/+cLLhdaSvKdaumWyHbm7HAk/bFwwyTuU0arR5yyCeW5GOoqt4tJTpDRxhpx9Q8kQL6vMpuw9hDSw==
|
integrity sha512-Q7DYAOi9O/+cLLhdaSvKdaumWyHbm7HAk/bFwwyTuU0arR5yyCeW5GOoqt4tJTpDRxhpx9Q8kQL6vMpuw9hDSw==
|
||||||
|
|
||||||
"@types/markdown-it@^0.0.7":
|
"@types/markdown-it-container@^2.0.2":
|
||||||
|
version "2.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/markdown-it-container/-/markdown-it-container-2.0.2.tgz#0e624653415a1c2f088a5ae51f7bfff480c03f49"
|
||||||
|
integrity sha512-T770GL+zJz8Ssh1NpLiOruYhrU96yb8ovPSegLrWY5XIkJc6PVVC7kH/oQaVD0rkePpWMFJK018OgS/pwviOMw==
|
||||||
|
dependencies:
|
||||||
|
"@types/markdown-it" "*"
|
||||||
|
|
||||||
|
"@types/markdown-it@*", "@types/markdown-it@^0.0.7":
|
||||||
version "0.0.7"
|
version "0.0.7"
|
||||||
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.7.tgz#75070485a3d8ad11e7deb8287f4430be15bf4d39"
|
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.7.tgz#75070485a3d8ad11e7deb8287f4430be15bf4d39"
|
||||||
integrity sha512-WyL6pa76ollQFQNEaLVa41ZUUvDvPY+qAUmlsphnrpL6I9p1m868b26FyeoOmo7X3/Ta/S9WKXcEYXUSHnxoVQ==
|
integrity sha512-WyL6pa76ollQFQNEaLVa41ZUUvDvPY+qAUmlsphnrpL6I9p1m868b26FyeoOmo7X3/Ta/S9WKXcEYXUSHnxoVQ==
|
||||||
|
@ -1674,6 +1681,11 @@ map-visit@^1.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
object-visit "^1.0.0"
|
object-visit "^1.0.0"
|
||||||
|
|
||||||
|
markdown-it-container@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdown-it-container/-/markdown-it-container-2.0.0.tgz#0019b43fd02eefece2f1960a2895fba81a404695"
|
||||||
|
integrity sha1-ABm0P9Au7+zi8ZYKKJX7qBpARpU=
|
||||||
|
|
||||||
markdown-it@^8.4.2:
|
markdown-it@^8.4.2:
|
||||||
version "8.4.2"
|
version "8.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
|
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
|
||||||
|
|
Loading…
Reference in a new issue