Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
- Plugin released to community plugin list
- Removed requirement to have the colon inside the parameters
  • Loading branch information
valentine195 committed Aug 5, 2021
1 parent 495eb4f commit 246d575
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Markdown Attributes for Obsidian.md

Allows the use of `{: .class id='id' data=value }` markdown attributes inside Obsidian.md.
Allows the use of `{ .class id='id' data=value }` markdown attributes inside Obsidian.md.

This plugin is currently proof of concept; however, no loss of data should occur. It is possible that rendering errors may happen. If so, please create an issue including the source text that caused the issue.

## Using the Plugin

Add your attributes inside a curly bracket with a colon, like this:

`{: .class }`
`{ .class }`

See below for usage with specific elements.

Expand All @@ -21,7 +21,7 @@ Currently, the ID attribute must be set using `id=value` due to Obsidian's tags.
Inline text elements such as italics, bold, highlight, etc. should have their attributes placed _inside_ the symbol:

```
I'm normal text, but *I'm italic {: class='italics' }*, **I'm bold {: .bold }** and ==I'm highlighted {: id=highlight }==.
I'm normal text, but *I'm italic { class='italics' }*, **I'm bold { .bold }** and ==I'm highlighted { id=highlight }==.
```

### Paragraphs
Expand All @@ -32,14 +32,14 @@ Paragraph attributes should be placed after the last line of the block.
This is a paragraph.
This is another line of the paragraph.
This is the last line.
{: id=my_paragraph .class }
{ id=my_paragraph .class }
```

### Headers

Attributes must be added to headers at the end of the line.

`### A Header {: id=header .header-class }`
`### A Header { id=header .header-class }`

### Tables

Expand All @@ -49,15 +49,15 @@ Attributes can be added to the `<table>` element by placing the attribute on the
| header1 | header2 |
| ------- | ------- |
| column1 | column2 |
{: .table-class}
{ .table-class}
```

Attributes can be added to individual table cells like so:

```markdown
| header1 {: .class} | header2 |
| header1 { .class} | header2 |
| ------------------ | ---------------------- |
| column1 | column2 {: .class-two} |
| column1 | column2 { .class-two} |
```

It is not currently possible to add attributes to `<tr>` or `<thead>` elements.
Expand All @@ -66,42 +66,42 @@ It is not currently possible to add attributes to `<tr>` or `<thead>` elements.

Both Wikilinks and markdown syntax links may have attributes placed on them.

`[link](http://example.com){: class="foo bar" title="Some title!" }`
`[link](http://example.com){ class="foo bar" title="Some title!" }`

`[[Test 123]] {: .wikilink}`
`[[Test 123]] { .wikilink}`

### Lists

Lists may have attributes placed on each individual list item.

```markdown
- item {: .item}
- nested item {: .nested}
- nested item 2 {: id="item 2" }
- item { .item}
- nested item { .nested}
- nested item 2 { id="item 2" }
```

Attributes can only be applied to the final nested list by placing the attribute on the line immediately following the last item.

```markdown
- item 1 {: .item}
- item 2 {: id=item }
- item 3 {: data-item=3 }
{: .top-level-ul }
- item 1 { .item}
- item 2 { id=item }
- item 3 { data-item=3 }
{ .top-level-ul }
```

```markdown
- item {: .item}
- nested item {: .nested}
- nested item 2 {: id="item 2" }
{: .nested-ul}
- item { .item}
- nested item { .nested}
- nested item 2 { id="item 2" }
{ .nested-ul}
```

### Code Blocks

Code blocks should have their attributes placed after the initial three ticks.

````
```python {: data-python="code" .class }
```python { data-python="code" .class }
nums = [x for x in range(10)]
```
````
Expand All @@ -112,7 +112,7 @@ nums = [x for x in range(10)]

# Installation

<!-- ## From within Obsidian
## From within Obsidian

From Obsidian v0.9.8, you can activate this plugin within Obsidian by doing the following:

Expand All @@ -121,7 +121,7 @@ From Obsidian v0.9.8, you can activate this plugin within Obsidian by doing the
- Click Browse community plugins
- Search for this plugin
- Click Install
- Once installed, close the community plugins window and activate the newly installed plugin -->
- Once installed, close the community plugins window and activate the newly installed plugin

## From GitHub

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "markdown-attributes",
"name": "Markdown Attributes",
"version": "0.0.7",
"version": "1.0.0",
"minAppVersion": "0.12.10",
"description": "Add markdown attributes to elements in Obsidian.md",
"author": "Jeremy Valentine",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-attributes",
"version": "0.0.7",
"version": "1.0.0",
"description": "Add markdown attributes to elements in Obsidian.md",
"main": "main.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ interface ElementWithAttributes {
}

export default class Processor {
static BASE_RE = /\{\:[ ]*([^\}\n ][^\}\n]*)[ ]*\}/;
static ONLY_RE = /^\{\:[ ]*([^\}\n ][^\}\n]*)[ ]*\}$/;
static BASE_RE = /\{\:?[ ]*([^\}\n ][^\}\n]*)[ ]*\}/;
static ONLY_RE = /^\{\:?[ ]*([^\}\n ][^\}\n]*)[ ]*\}$/;
static BLOCK_RE = /\n[ ]*\{\:?[ ]*([^\}\n ][^\}\n]*)[ ]*\}[ ]*$/;

constructor(private topLevelElement: HTMLElement) {}
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"0.0.7": "0.12.0"
"0.0.7": "0.12.0",
"1.0.0": "0.12.0"
}

0 comments on commit 246d575

Please sign in to comment.