Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
aa8995dc
Commit
aa8995dc
authored
Jan 24, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jan 24, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render annotation markdown text to HTML when exporting to that format
parent
b4857fe7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
8 deletions
+35
-8
annotations-exporter.tsx
src/sidebar/services/annotations-exporter.tsx
+17
-3
annotations-exporter-test.js
src/sidebar/services/test/annotations-exporter-test.js
+18
-5
No files found.
src/sidebar/services/annotations-exporter.tsx
View file @
aa8995dc
...
@@ -14,6 +14,7 @@ import {
...
@@ -14,6 +14,7 @@ import {
import
{
annotationDisplayName
}
from
'../helpers/annotation-user'
;
import
{
annotationDisplayName
}
from
'../helpers/annotation-user'
;
import
{
stripInternalProperties
}
from
'../helpers/strip-internal-properties'
;
import
{
stripInternalProperties
}
from
'../helpers/strip-internal-properties'
;
import
{
VersionData
}
from
'../helpers/version-data'
;
import
{
VersionData
}
from
'../helpers/version-data'
;
import
{
renderMathAndMarkdown
}
from
'../render-markdown'
;
import
{
formatDateTime
}
from
'../util/time'
;
import
{
formatDateTime
}
from
'../util/time'
;
export
type
JSONExportContent
=
{
export
type
JSONExportContent
=
{
...
@@ -203,7 +204,7 @@ export class AnnotationsExporter {
...
@@ -203,7 +204,7 @@ export class AnnotationsExporter {
</
p
>
</
p
>
<
table
>
<
table
>
<
tbody
>
<
tbody
style=
{
{
verticalAlign
:
'top'
}
}
>
<
tr
>
<
tr
>
<
td
>
Group:
</
td
>
<
td
>
Group:
</
td
>
<
td
>
{
groupName
}
</
td
>
<
td
>
{
groupName
}
</
td
>
...
@@ -233,12 +234,21 @@ export class AnnotationsExporter {
...
@@ -233,12 +234,21 @@ export class AnnotationsExporter {
{
annotations
.
map
((
annotation
,
index
)
=>
{
{
annotations
.
map
((
annotation
,
index
)
=>
{
const
page
=
pageLabel
(
annotation
);
const
page
=
pageLabel
(
annotation
);
const
annotationQuote
=
quote
(
annotation
);
const
annotationQuote
=
quote
(
annotation
);
const
renderedComment
=
renderMathAndMarkdown
(
annotation
.
text
);
// When the result of rendering the text's markdown is just a
// single paragraph, we fall back to the annotation text, to
// avoid extra margins added by some editors, like Google Docs
const
comment
=
renderedComment
===
`<p>${annotation.text}</p>`
?
annotation
.
text
:
renderedComment
;
return
(
return
(
<
article
key=
{
annotation
.
id
}
>
<
article
key=
{
annotation
.
id
}
>
<
h2
>
Annotation
{
index
+
1
}
:
</
h2
>
<
h2
>
Annotation
{
index
+
1
}
:
</
h2
>
<
table
>
<
table
>
<
tbody
>
<
tbody
style=
{
{
verticalAlign
:
'top'
}
}
>
<
tr
>
<
tr
>
<
td
>
Created at:
</
td
>
<
td
>
Created at:
</
td
>
<
td
>
<
td
>
...
@@ -273,7 +283,11 @@ export class AnnotationsExporter {
...
@@ -273,7 +283,11 @@ export class AnnotationsExporter {
)
}
)
}
<
tr
>
<
tr
>
<
td
>
Comment:
</
td
>
<
td
>
Comment:
</
td
>
<
td
>
{
annotation
.
text
}
</
td
>
<
td
dangerouslySetInnerHTML=
{
{
__html
:
comment
,
}
}
/>
</
tr
>
</
tr
>
{
annotation
.
tags
.
length
>
0
&&
(
{
annotation
.
tags
.
length
>
0
&&
(
<
tr
>
<
tr
>
...
...
src/sidebar/services/test/annotations-exporter-test.js
View file @
aa8995dc
...
@@ -291,6 +291,12 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
...
@@ -291,6 +291,12 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
const
annotations
=
[
const
annotations
=
[
{
{
...
baseAnnotation
,
...
baseAnnotation
,
text
:
`This includes markdown
1. First item
2. Second item
**bold text** and [a link](https://example.com)`
,
user
:
'acct:jane@localhost'
,
user
:
'acct:jane@localhost'
,
tags
:
[
'foo'
,
'bar'
],
tags
:
[
'foo'
,
'bar'
],
target
:
targetWithSelectors
(
quoteSelector
(
'The quote'
)),
target
:
targetWithSelectors
(
quoteSelector
(
'The quote'
)),
...
@@ -343,7 +349,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
...
@@ -343,7 +349,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
</a>
</a>
</p>
</p>
<table>
<table>
<tbody>
<tbody
style="vertical-align:top;"
>
<tr>
<tr>
<td>Group:</td>
<td>Group:</td>
<td>My group</td>
<td>My group</td>
...
@@ -373,7 +379,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
...
@@ -373,7 +379,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
<article>
<article>
<h2>Annotation 1:</h2>
<h2>Annotation 1:</h2>
<table>
<table>
<tbody>
<tbody
style="vertical-align:top;"
>
<tr>
<tr>
<td>Created at:</td>
<td>Created at:</td>
<td>
<td>
...
@@ -396,7 +402,14 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
...
@@ -396,7 +402,14 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
</tr>
</tr>
<tr>
<tr>
<td>Comment:</td>
<td>Comment:</td>
<td>Annotation text</td>
<td>
<p>This includes markdown</p>
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
<p><strong>bold text</strong> and <a href="https://example.com" target="_blank">a link</a></p>
</td>
</tr>
</tr>
<tr>
<tr>
<td>Tags:</td>
<td>Tags:</td>
...
@@ -408,7 +421,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
...
@@ -408,7 +421,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
<article>
<article>
<h2>Annotation 2:</h2>
<h2>Annotation 2:</h2>
<table>
<table>
<tbody>
<tbody
style="vertical-align:top;"
>
<tr>
<tr>
<td>Created at:</td>
<td>Created at:</td>
<td>
<td>
...
@@ -447,7 +460,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
...
@@ -447,7 +460,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
<article>
<article>
<h2>Annotation 3:</h2>
<h2>Annotation 3:</h2>
<table>
<table>
<tbody>
<tbody
style="vertical-align:top;"
>
<tr>
<tr>
<td>Created at:</td>
<td>Created at:</td>
<td>
<td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment