-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
206 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/example.csf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import unittest | ||
from pathlib import Path | ||
|
||
from md2conf.api import ConfluenceAPI | ||
from md2conf.converter import content_to_string | ||
|
||
TEST_SPACE = "DAP" | ||
TEST_PAGE_ID = "86918529216" | ||
|
||
|
||
class TestConfluenceStorageFormat(unittest.TestCase): | ||
test_dir: Path | ||
|
||
def setUp(self) -> None: | ||
self.test_dir = Path(__file__).parent | ||
parent_dir = self.test_dir.parent | ||
|
||
self.sample_dir = parent_dir / "sample" | ||
|
||
def test_markdown(self) -> None: | ||
with ConfluenceAPI() as api: | ||
page = api.get_page(TEST_PAGE_ID, space_key=TEST_SPACE) | ||
|
||
with open(self.test_dir / "example.csf", "w") as f: | ||
f.write(content_to_string(page.content)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pathlib | ||
|
||
import pymdownx.emoji1_db as emoji_db | ||
|
||
|
||
def generate_source(path: pathlib.Path) -> None: | ||
"Generates a source Markdown document for testing emojis." | ||
|
||
emojis = emoji_db.emoji | ||
|
||
with open(path, "w") as f: | ||
print("<!-- confluence-page-id: 86918529216 -->", file=f) | ||
print("<!-- This file has been generated by a script. -->", file=f) | ||
print(file=f) | ||
print("## Emoji", file=f) | ||
print(file=f) | ||
print("| Icon | Emoji code |", file=f) | ||
print("| ---- | ---------- |", file=f) | ||
for key in emojis.keys(): | ||
key = key.strip(":") | ||
print(f"| :{key}: | `:{key}:` |", file=f) | ||
|
||
|
||
def generate_target(path: pathlib.Path) -> None: | ||
"Generates a target Confluence Storage Format (XML) document for testing emojis." | ||
|
||
emojis = emoji_db.emoji | ||
|
||
with open(path, "w") as f: | ||
print('<ac:structured-macro ac:name="info" ac:schema-version="1">', file=f) | ||
print("<ac:rich-text-body>", file=f) | ||
print("<p>This page has been generated with a tool.</p>", file=f) | ||
print("</ac:rich-text-body>", file=f) | ||
print("</ac:structured-macro>", file=f) | ||
print("<h2>Emoji</h2>", file=f) | ||
print("<table>", file=f) | ||
print("<thead><tr><th>Icon</th><th>Emoji code</th></tr></thead>", file=f) | ||
print("<tbody>", file=f) | ||
for key, data in emojis.items(): | ||
key = key.strip(":") | ||
unicode = "".join(f"&#x{item};" for item in data["unicode"].split("-")) | ||
|
||
print( | ||
f'<tr><td><ac:emoticon ac:name="blue-star" ac:emoji-shortname=":{key}:" ac:emoji-fallback="{unicode}"/></td><td><code>:{key}:</code></td></tr>', | ||
file=f, | ||
) | ||
print("</tbody>", file=f) | ||
print("</table>", file=f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import sys | ||
|
||
if sys.version_info >= (3, 9): | ||
|
||
def removeprefix(string: str, prefix: str) -> str: | ||
"If the string starts with the prefix, return the string without the prefix; otherwise, return the original string." | ||
|
||
return string.removeprefix(prefix) | ||
|
||
else: | ||
|
||
def removeprefix(string: str, prefix: str) -> str: | ||
"If the string starts with the prefix, return the string without the prefix; otherwise, return the original string." | ||
|
||
if string.startswith(prefix): | ||
prefix_len = len(prefix) | ||
return string[prefix_len:] | ||
else: | ||
return string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/emoji.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/emoji.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters