Skip to content

Commit

Permalink
fix(NcRichText): unlock tests, patch component
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Feb 7, 2025
1 parent d5043f6 commit dcc017a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cypress/component/richtext.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mount } from 'cypress/vue2'
import NcRichText from '../../src/components/NcRichText/NcRichText.vue'

describe('NcRichText', () => {
describe.only('XML-like text (escaped and unescaped)', () => {
describe('XML-like text (escaped and unescaped)', () => {
const TEST = '<span>text</span> &lt;span&gt;text&lt;/span&gt;'
it('renders normal text as passed', () => {
mount(NcRichText, {
Expand Down
4 changes: 3 additions & 1 deletion src/components/NcRichText/NcRichText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,9 @@ export default {
})
.processSync(this.text
// escape special symbol "<" to not treat text as HTML
.replace(/<[^>]+>/g, (match) => match.replace(/</g, '&lt;')),
.replace(/<[^>]+>/g, (match) => match.replace(/</g, '&lt;'))
// unescape special symbol ">" to parse blockquotes
.replace(/&gt;/gmi, '>'),
)
.result

Expand Down
2 changes: 1 addition & 1 deletion src/components/NcRichText/remarkUnescape.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { visit, SKIP } from 'unist-util-visit'

export const remarkUnescape = function() {
return function(tree) {
visit(tree, (node) => node.type === 'text' || node.type === 'code',
visit(tree, (node) => ['text', 'code', 'inlineCode'].includes(node.type),
(node, index, parent) => {
parent.children.splice(index, 1, {
...node,
Expand Down

0 comments on commit dcc017a

Please sign in to comment.