Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.

Commit e3948ef

Browse files
authored
Merge pull request #161 from trey-wallis/dev
Basic markdown syntax
2 parents b60a542 + 8a9c173 commit e3948ef

File tree

24 files changed

+588
-93
lines changed

24 files changed

+588
-93
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Please upgrade your tables to this new format. This update also includes several
1616

1717
## What's New?
1818

19+
### Version 3.4.0
20+
21+
- The pound sign `#` in tags are now optional. See `Tags` below for more details.
22+
- NLT now supports bold, italics, highlight and underline. See `Markdown` below for more details.
23+
1924
### Version 3.3.0
2025

2126
- Line break elements are now supported for cells in a column with the type `text` selected. See `Line Breaks` below for usage information
@@ -116,6 +121,26 @@ To edit a cell, just click on it. An input, textarea or menu will appear which w
116121

117122
Text can be rendered in cells that are in a column with the `text` type selected.
118123

124+
#### Markdown
125+
126+
To bold text use either double astericks `**` or the bold tag `<b>
127+
128+
- `**This is bold**`
129+
- `<b>This is bold</b>`
130+
131+
To italicize text use either single astericks `*` or the italics tag `<i>
132+
133+
- `*This is italicized*`
134+
- `<i>This is italicized</i>`
135+
136+
To highlight text use the double equal sign syntax `==`
137+
138+
- `==This is highlighted==`
139+
140+
To underline text use the underline tag `<u>`
141+
142+
- `<u>This is underlined</u>`
143+
119144
#### Links
120145

121146
Links can be rendered in cells that are in a column with the `text` column type is selected. To render a link, add double squares surrounding text `[[My Link]]`.
@@ -136,7 +161,11 @@ Line breaks can be added using the break line HTML tag `<br>`. For example, if y
136161

137162
### Tags
138163

139-
Tags can be rendered in cells that are in a column with the `tag` type selected. Tags have a special notion-like menu that will appear. Tags are scoped to each column of a table. You can type text to filter existing tags and select one. You can also create a new tag by typing text and clicking "Create New" or pressing enter.
164+
Tags can be rendered in cells that are in a column with the `tag` type selected.
165+
166+
Tags have a special notion-like menu that will appear. Tags are scoped to each column of a table. You can type text to filter existing tags and select one. You can also create a new tag by typing text and clicking "Create New" or pressing enter.
167+
168+
Tags can be rendered with or without a pound sign `#`. If you use a pound sign, then the tag will be rendered as a internal Obsidian tag link. Otherwise, it will be rendered as plain text.
140169

141170
![Screenshot](https://raw.githubusercontent.com/trey-wallis/obsidian-notion-like-tables/master/.readme/tag-menu.png)
142171

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"author": "Trey Wallis",
77
"authorUrl": "https://github.com/trey-wallis",
88
"isDesktopOnly": false,
9-
"version": "3.3.2"
9+
"version": "3.4.0"
1010
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-notion-like-tables",
3-
"version": "3.3.2",
3+
"version": "3.4.0",
44
"description": "Notion-like tables for Obsidian.md",
55
"main": "main.js",
66
"scripts": {

src/app/components/EditableTd/index.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import TagCellEdit from "../TagCellEdit";
1616

1717
import { useMenu } from "../MenuProvider";
1818
import { randomColor } from "src/app/services/random";
19-
import { addPound } from "src/app/services/string/adders";
2019
import { Tag } from "src/app/services/appData/state/tag";
2120
import { Cell } from "src/app/services/appData/state/cell";
2221
import {
@@ -119,12 +118,7 @@ export default function EditableTd({
119118
if (DEBUG.EDITABLE_TD.HANDLER)
120119
console.log("[EditableTd] handleCellContextClick()");
121120
try {
122-
let text = content;
123-
if (type === CELL_TYPE.TAG) {
124-
const tag = tags.find((tag) => tag.selected.includes(id));
125-
text = addPound(tag.content);
126-
}
127-
await navigator.clipboard.writeText(text);
121+
await navigator.clipboard.writeText(content);
128122
new Notice("Cell text copied");
129123
} catch (err) {
130124
console.log(err);

src/app/components/TagCell/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export default function TagCell({
4545
if (content === "") return <></>;
4646

4747
//If on render view, add the link to make it a clickable tag
48-
if (showLink) content = toTagLink(content);
48+
if (showLink) {
49+
if (content.startsWith("#")) content = toTagLink(content);
50+
}
4951

5052
return (
5153
<div

src/app/components/TagCellEdit/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export default function TagCellEdit({
5555
);
5656

5757
function handleTextChange(e: React.ChangeEvent<HTMLInputElement>) {
58-
//Disallow pound
59-
if (e.target.value.match("#")) return;
6058
//Disallow whitespace
6159
if (e.target.value.match(/\s/)) return;
6260
onInputChange(e.target.value);
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import React from "react";
22

33
import parse from "html-react-parser";
4-
import { parseFileLinks, parseURLs } from "src/app/services/string/parsers";
4+
import {
5+
parseFileLinks,
6+
parseURLs,
7+
parseBoldMarkdown,
8+
parseItalicMarkdown,
9+
parseHighlightMarkdown,
10+
} from "src/app/services/string/parsers";
511
interface Props {
612
text: string;
713
}
814

915
export default function TextCell({ text }: Props) {
1016
text = parseURLs(text);
1117
text = parseFileLinks(text);
18+
text = parseBoldMarkdown(text);
19+
text = parseItalicMarkdown(text);
20+
text = parseHighlightMarkdown(text);
1221

1322
return <p className="NLT__p">{parse(text)}</p>;
1423
}

src/app/constants.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const DEBUG = {
22
LOAD_APP_DATA: {
3-
DATA: false,
3+
DATA: true,
44
IDS: false,
55
TYPES: false,
6-
PARSED_TABLE: true,
6+
PARSED_TABLE: false,
77
},
88
APP: {
99
HANDLER: false,
@@ -102,3 +102,14 @@ export const MENU_LEVEL = {
102102

103103
export const BREAK_LINE_TAG = "<br>";
104104
export const AMPERSAND = "&";
105+
export const BOLD_TAG_MARKDOWN = "**";
106+
export const ITALIC_TAG_MARKDOWN = "*";
107+
export const HIGHLIGHT_TAG_MARKDOWN = "==";
108+
export const UNDERLINE_TAG_START = "<u>";
109+
export const UNDERLINE_TAG_CLOSE = "</u>";
110+
export const ITALIC_TAG_START = "<i>";
111+
export const ITALIC_TAG_CLOSE = "</i>";
112+
export const BOLD_TAG_START = "<b>";
113+
export const BOLD_TAG_CLOSE = "</b>";
114+
export const HIGHLIGHT_TAG_START = "<mark>";
115+
export const HIGHLIGHT_TAG_CLOSE = "</mark>";

src/app/services/appData/external/merge.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ describe("updateAppDataFromSavedState", () => {
7878
const merged = updateAppDataFromSavedState(oldAppData, newAppData);
7979
expect(merged.tags[0].color).toEqual(newAppData.tags[0].color);
8080
expect(merged.tags[1].color).toEqual(oldAppData.tags[1].color);
81-
expect(merged.tags[0].content).toEqual("tag1-updated");
82-
expect(merged.tags[1].content).toEqual("tag2");
81+
expect(merged.tags[0].content).toEqual("#tag1-updated");
82+
expect(merged.tags[1].content).toEqual("#tag2");
8383
});
8484

8585
it("merges header sort name", () => {

src/app/services/appData/external/saveUtils.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ describe("findAppData", () => {
7878
"column-id-345678",
7979
"table-id-123456",
8080
],
81-
["#tag1", "#tag2", "#tag3", "row-id-123456"],
81+
["tag1", "#tag2", "#tag3", "row-id-123456"],
8282
];
8383
const data = findAppData(parsedTable);
8484
expect(data.tags.length).toEqual(3);
8585
expect(data.tags[0].content).toEqual("tag1");
86-
expect(data.tags[1].content).toEqual("tag2");
87-
expect(data.tags[2].content).toEqual("tag3");
86+
expect(data.tags[1].content).toEqual("#tag2");
87+
expect(data.tags[2].content).toEqual("#tag3");
8888
});
8989

9090
it("finds errors", () => {
@@ -97,7 +97,7 @@ describe("findAppData", () => {
9797
"column-id-345678",
9898
"table-id-123456",
9999
],
100-
["tag1", "#tag2", "#tag3", "row-id-123456"],
100+
["tag1 ok", "#tag2", "#tag3", "row-id-123456"],
101101
];
102102
const data = findAppData(parsedTable);
103103
expect(data.cells[0].type).toEqual(CELL_TYPE.ERROR);

0 commit comments

Comments
 (0)