Commit e137331e authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '223097-support-fenced-code-blocks-in-atlassian-document-format-converter' into 'master'

Support fenced code blocks in Atlassian Document Format converter

Closes #223097

See merge request gitlab-org/gitlab!35065
parents 880f715d 3a815bf8
---
title: Support fenced code blocks in Atlassian Document Format converter
merge_request: 35065
author:
type: fixed
......@@ -12,6 +12,46 @@ module Kramdown
# Note: this is only an initial implementation. Currently don't
# strip out IALs or other specific kramdown syntax.
class Commonmark < ::Kramdown::Converter::Kramdown
# replaces the ^ used in kramdown. This forces the current
# block to end, so that a different list or codeblock can be
# started. https://kramdown.gettalong.org/syntax.html#eob-marker
END_OF_BLOCK = '<!-- -->'
def convert(el, opts = { indent: 0 })
res = super
if [:ul, :dl, :ol, :codeblock].include?(el.type) && opts[:next] &&
([el.type, :codeblock].include?(opts[:next].type) ||
(opts[:next].type == :blank && opts[:nnext] &&
[el.type, :codeblock].include?(opts[:nnext].type)))
# replace the end of block character
res.sub!(/\^\n\n\z/m, "#{END_OF_BLOCK}\n\n")
end
res
end
def convert_codeblock(el, _opts)
# Although tildes are supported in CommonMark, backticks are more common
"```#{el.options[:lang]}\n" +
el.value.split(/\n/).map {|l| l.empty? ? "" : "#{l}" }.join("\n") +
"\n```\n\n"
end
def convert_li(el, opts)
res = super
if el.children.first && el.children.first.type == :p && !el.children.first.options[:transparent]
if el.children.size == 1 && @stack.last.children.last == el &&
(@stack.last.children.any? {|c| c.children.first.type != :p } || @stack.last.children.size == 1)
# replace the end of block character
res.sub!(/\^\n\z/m, "#{END_OF_BLOCK}\n")
end
end
res
end
def convert_table(el, opts)
return super unless @options[:html_tables]
......
......@@ -14,6 +14,18 @@
}
]
},
{
"type": "codeBlock",
"attrs": {
"language": "css"
},
"content": [
{
"type": "text",
"text": ".overflow { overflow: hidden; }"
}
]
},
{
"type": "bulletList",
"content": [
......@@ -37,6 +49,37 @@
"text": "public DemoClass()\n{\n // assign default value\n x = 0;\n}"
}
]
},
{
"type": "orderedList",
"content": [
{
"type": "listItem",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Number list Item 1"
}
]
},
{
"type": "codeBlock",
"attrs": {
"language": "ruby"
},
"content": [
{
"type": "text",
"text": "def test\n # assign default value\n x = 0\nend"
}
]
}
]
}
]
}
]
}
......
export function makeIssue({ parentIssue, project, users }) {
const issueType = pickRandom(project.issueTypes)
console.log(data)
return data
}
```javascript
export function makeIssue({ parentIssue, project, users }) {
const issueType = pickRandom(project.issueTypes)
console.log(data)
return data
}
```
<!-- -->
```css
.overflow { overflow: hidden; }
```
* Item 1
public DemoClass()
{
// assign default value
x = 0;
}
```java
public DemoClass()
{
// assign default value
x = 0;
}
```
1. Number list Item 1
```ruby
def test
# assign default value
x = 0
end
```
......@@ -165,37 +165,40 @@ Col 3 Row 3
<del>Strikethrough</del>
export function makeIssue({ parentIssue, project, users }) {
const issueType = pickRandom(project.issueTypes)
let data = {
fields: {
summary: faker.lorem.sentence(),
issuetype: {
id: issueType.id
},
project: {
id: project.id
},
reporter: {
id: pickRandom(users)
}
}
```javascript
export function makeIssue({ parentIssue, project, users }) {
const issueType = pickRandom(project.issueTypes)
let data = {
fields: {
summary: faker.lorem.sentence(),
issuetype: {
id: issueType.id
},
project: {
id: project.id
},
reporter: {
id: pickRandom(users)
}
if (issueType.subtask) {
data = {
parent: {
key: parentIssue
}
}
}
}
if (issueType.subtask) {
data = {
parent: {
key: parentIssue
}
console.log(data)
return data
}
}
console.log(data)
return data
}
```
![jira-10050-field-description](adf-media://79411c6b-50e0-477f-b4ed-ac3a5887750c)
......
......@@ -146,6 +146,25 @@
]
}
]
},
{
"type": "orderedList",
"content": [
{
"type": "listItem",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Another list"
}
]
}
]
}
]
}
]
}
......@@ -17,4 +17,9 @@
9. Number list item 9
10. Number list item 10
<!-- -->
1. Another list
<!-- -->
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment