Compare commits

...

4 Commits

Author SHA1 Message Date
github-actions[bot]
b2b4fbdf12 Version Packages (#1010)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-14 12:06:36 -03:00
Luccas Mateus
099f3c5204 [@portaljs/ckan][sm] - fix types (#1009) 2023-08-14 11:16:51 -03:00
github-actions[bot]
17ad9558e1 Version Packages (#1008)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-14 16:07:19 +02:00
Ola Rubaj
6418dbb7e2 [#1005, remark-wiki-link]: Parse note embeds as regular wiki links (#1006) 2023-08-14 15:23:28 +02:00
10 changed files with 95 additions and 26 deletions

View File

@@ -1,5 +1,11 @@
# @portaljs/ckan
## 0.0.4
### Patch Changes
- [#1009](https://github.com/datopian/portaljs/pull/1009) [`099f3c52`](https://github.com/datopian/portaljs/commit/099f3c520407a7215b5b41f67dc8ea5ac73d07c4) Thanks [@luccasmmg](https://github.com/luccasmmg)! - added package_count to organization type
## 0.0.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@portaljs/ckan",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"description": "https://portaljs.org",
"keywords": [

View File

@@ -1,6 +1,6 @@
import { Activity } from "./activity.interface";
import { Dataset, Tag } from "./dataset.interface";
import { User } from "./user.interface";
import { Activity } from './activity.interface';
import { Dataset, Tag } from './dataset.interface';
import { User } from './user.interface';
export interface Group {
display_name: string;
@@ -10,9 +10,9 @@ export interface Group {
created: string;
name: string;
is_organization: false;
state: "active" | "deleted" | "inactive";
state: 'active' | 'deleted' | 'inactive';
image_url: string;
type: "group";
type: 'group';
title: string;
revision_id: string;
num_followers: number;

View File

@@ -1,6 +1,6 @@
import { Activity } from "./activity.interface";
import { Dataset, Tag } from "./dataset.interface";
import { User } from "./user.interface";
import { Activity } from './activity.interface';
import { Dataset, Tag } from './dataset.interface';
import { User } from './user.interface';
export interface Organization {
id: string;
@@ -13,8 +13,9 @@ export interface Organization {
image_display_url?: string;
created?: string;
is_organization: boolean;
approval_status?: "approved";
state: "active";
package_count: number;
approval_status?: 'approved';
state: 'active';
packages?: Array<Dataset>;
activity_stream?: Array<Activity>;
users?: Array<User>;

View File

@@ -1,5 +1,11 @@
# @portaljs/remark-wiki-link
## 1.1.0
### Minor Changes
- [#1006](https://github.com/datopian/portaljs/pull/1006) [`6418dbb7`](https://github.com/datopian/portaljs/commit/6418dbb7e246fa17b56840c64daa043112dc9189) Thanks [@olayway](https://github.com/olayway)! - Parse note embeds as regular wiki links (until we add proper support for note embeds).
## 1.0.4
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@portaljs/remark-wiki-link",
"version": "1.0.4",
"version": "1.1.0",
"description": "Parse and render wiki-style links in markdown especially Obsidian style links.",
"repository": {
"type": "git",

View File

@@ -15,9 +15,9 @@ const defaultWikiLinkResolver = (target: string) => {
export interface FromMarkdownOptions {
pathFormat?:
| "raw" // default; use for regular relative or absolute paths
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
| "raw" // default; use for regular relative or absolute paths
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
permalinks?: string[]; // list of permalinks to match possible permalinks of a wiki link against
wikiLinkResolver?: (name: string) => string[]; // function to resolve wiki links to an array of possible permalinks
newClassName?: string; // class name to add to links that don't have a matching permalink
@@ -125,13 +125,24 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) {
if (isEmbed) {
const [isSupportedFormat, format] = isSupportedFileFormat(target);
if (!isSupportedFormat) {
wikiLink.data.hName = "p";
wikiLink.data.hChildren = [
{
type: "text",
value: `![[${target}]]`,
},
];
// Temporarily render note transclusion as a regular wiki link
if (!format) {
wikiLink.data.hName = "a";
wikiLink.data.hProperties = {
className: classNames + " " + "transclusion",
href: hrefTemplate(link) + headingId,
};
wikiLink.data.hChildren = [{ type: "text", value: displayName }];
} else {
wikiLink.data.hName = "p";
wikiLink.data.hChildren = [
{
type: "text",
value: `![[${target}]]`,
},
];
}
} else if (format === "pdf") {
wikiLink.data.hName = "iframe";
wikiLink.data.hProperties = {

View File

@@ -15,9 +15,9 @@ const defaultWikiLinkResolver = (target: string) => {
export interface HtmlOptions {
pathFormat?:
| "raw" // default; use for regular relative or absolute paths
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
| "raw" // default; use for regular relative or absolute paths
| "obsidian-absolute" // use for Obsidian-style absolute paths (with no leading slash)
| "obsidian-short"; // use for Obsidian-style shortened paths (shortest path possible)
permalinks?: string[]; // list of permalinks to match possible permalinks of a wiki link against
wikiLinkResolver?: (name: string) => string[]; // function to resolve wiki links to an array of possible permalinks
newClassName?: string; // class name to add to links that don't have a matching permalink
@@ -108,7 +108,16 @@ function html(opts: HtmlOptions = {}) {
if (isEmbed) {
const [isSupportedFormat, format] = isSupportedFileFormat(target);
if (!isSupportedFormat) {
this.raw(`![[${target}]]`);
// Temporarily render note transclusion as a regular wiki link
if (!format) {
this.tag(
`<a href="${hrefTemplate(link + headingId)}" class="${classNames} transclusion">`
);
this.raw(displayName);
this.tag("</a>");
} else {
this.raw(`![[${target}]]`);
}
} else if (format === "pdf") {
this.tag(
`<iframe width="100%" src="${hrefTemplate(

View File

@@ -309,4 +309,16 @@ describe("micromark-extension-wiki-link", () => {
expect(serialized).toBe('<p><a href="/" class="internal">/index</a></p>');
});
});
describe("transclusions", () => {
test("parsers a transclusion as a regular wiki link", () => {
const serialized = micromark("![[Some Page]]", "ascii", {
extensions: [syntax()],
htmlExtensions: [html() as any], // TODO type fix
});
expect(serialized).toBe(
'<p><a href="Some Page" class="internal new transclusion">Some Page</a></p>'
);
});
});
});

View File

@@ -535,4 +535,28 @@ describe("remark-wiki-link", () => {
});
});
});
describe("transclusions", () => {
test("replaces a transclusion with a regular wiki link", () => {
const processor = unified().use(markdown).use(wikiLinkPlugin);
let ast = processor.parse("![[Some Page]]");
ast = processor.runSync(ast);
expect(select("wikiLink", ast)).not.toEqual(null);
visit(ast, "wikiLink", (node: Node) => {
expect(node.data?.isEmbed).toEqual(true);
expect(node.data?.exists).toEqual(false);
expect(node.data?.permalink).toEqual("Some Page");
expect(node.data?.alias).toEqual(null);
expect(node.data?.hName).toEqual("a");
expect((node.data?.hProperties as any).className).toEqual(
"internal new transclusion"
);
expect((node.data?.hProperties as any).href).toEqual("Some Page");
expect((node.data?.hChildren as any)[0].value).toEqual("Some Page");
});
});
});
});