Skip to content

Commit

Permalink
Add support for underscore in project key #50
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0l92 committed Jan 11, 2023
1 parent f6b53fe commit 00fd967
Show file tree
Hide file tree
Showing 9 changed files with 725 additions and 149 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-jira-issue",
"name": "Jira Issue",
"version": "1.49.0",
"version": "1.50.0",
"minAppVersion": "0.12.0",
"description": "This plugin allows you to track the progress of Atlassian Jira issues from your Obsidian notes.",
"author": "marc0l92",
Expand Down
842 changes: 708 additions & 134 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-jira-issue",
"version": "1.49.0",
"version": "1.50.0",
"description": "This plugin allows you to track the progress of [Atlassian Jira](https://www.atlassian.com/software/jira) issues from your [Obsidian](https://obsidian.md/) notes.",
"main": "src/main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/settingsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const COLOR_SCHEMA_DESCRIPTION = {

export const COMPACT_SYMBOL = '-'
export const COMMENT_REGEX = /^\s*#/
export const JIRA_KEY_REGEX = '[A-Z][A-Z0-9_]*-[0-9]+'

export interface IJiraIssueSettings {
accounts: IJiraIssueAccountSettings[]
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/inlineIssueRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MarkdownPostProcessorContext } from "obsidian"
import JiraClient from "../client/jiraClient"
import { IJiraIssue } from "../interfaces/issueInterfaces"
import { COMPACT_SYMBOL } from "../interfaces/settingsInterfaces"
import { COMPACT_SYMBOL, JIRA_KEY_REGEX } from "../interfaces/settingsInterfaces"
import ObjectsCache from "../objectsCache"
import { SettingsData } from "../settings"
import RC from "./renderingCommon"
Expand All @@ -11,7 +11,7 @@ import RC from "./renderingCommon"
function convertInlineIssuesToTags(el: HTMLElement): void {
if (SettingsData.inlineIssuePrefix) {
let match
while (match = new RegExp(`${SettingsData.inlineIssuePrefix}(${COMPACT_SYMBOL}?)([A-Z0-9]+-[0-9]+)`).exec(el.innerHTML)) {
while (match = new RegExp(`${SettingsData.inlineIssuePrefix}(${COMPACT_SYMBOL}?)(${JIRA_KEY_REGEX})`).exec(el.innerHTML)) {
// console.log({ match })
const compact = !!match[1]
const issueKey = match[2]
Expand Down
6 changes: 3 additions & 3 deletions src/rendering/inlineIssueViewPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SettingsData } from "../settings"
import RC from "./renderingCommon"
import escapeStringRegexp from 'escape-string-regexp'
import { getAccountByHost } from "../utils"
import { COMPACT_SYMBOL } from "../interfaces/settingsInterfaces"
import { COMPACT_SYMBOL, JIRA_KEY_REGEX } from "../interfaces/settingsInterfaces"

interface IMatchDecoratorRef {
ref: MatchDecorator
Expand Down Expand Up @@ -75,7 +75,7 @@ let jiraUrlMatchDecorator: IMatchDecoratorRef = { ref: null }
function buildMatchDecorators() {
if (SettingsData.inlineIssuePrefix !== '') {
jiraTagMatchDecorator.ref = new MatchDecorator({
regexp: new RegExp(`${SettingsData.inlineIssuePrefix}(${COMPACT_SYMBOL}?)([A-Z0-9]+-[0-9]+)`, 'g'),
regexp: new RegExp(`${SettingsData.inlineIssuePrefix}(${COMPACT_SYMBOL}?)(${JIRA_KEY_REGEX})`, 'g'),
decoration: (match: RegExpExecArray, view: EditorView, pos: number) => {
const compact = !!match[1]
const key = match[2]
Expand All @@ -100,7 +100,7 @@ function buildMatchDecorators() {
const urls: string[] = []
SettingsData.accounts.forEach(account => urls.push(escapeRegexp(account.host)))
jiraUrlMatchDecorator.ref = new MatchDecorator({
regexp: new RegExp(`(${COMPACT_SYMBOL}?)(${urls.join('|')})/browse/([A-Z0-9]+-[0-9]+)`, 'g'),
regexp: new RegExp(`(${COMPACT_SYMBOL}?)(${urls.join('|')})/browse/(${JIRA_KEY_REGEX})`, 'g'),
decoration: (match: RegExpExecArray, view: EditorView, pos: number) => {
const compact = !!match[1]
const host = match[2]
Expand Down
6 changes: 3 additions & 3 deletions src/rendering/issueFenceRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { IJiraIssue } from "../interfaces/issueInterfaces"
import JiraClient from "../client/jiraClient"
import ObjectsCache from "../objectsCache"
import RC from "./renderingCommon"
import { COMMENT_REGEX } from "../interfaces/settingsInterfaces"
import { COMMENT_REGEX, JIRA_KEY_REGEX } from "../interfaces/settingsInterfaces"

const ISSUE_REGEX = /^\s*([A-Z0-9]+-[0-9]+)\s*$/i
const ISSUE_LINK_REGEX = /\/([A-Z0-9]+-[0-9]+)\s*$/i
const ISSUE_REGEX = new RegExp(`^\s*(${JIRA_KEY_REGEX})\s*$`, 'i')
const ISSUE_LINK_REGEX = new RegExp(`\/(${JIRA_KEY_REGEX})\s*$`, 'i')

function getIssueKey(line: string): string | null {
if (COMMENT_REGEX.test(line)) {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@
"1.47.0": "0.12.0",
"1.48.0": "0.12.0",
"1.48.1": "0.12.0",
"1.49.0": "0.12.0"
"1.49.0": "0.12.0",
"1.50.0": "0.12.0"
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ color-name@~1.1.4:

colorsys@^1.0.22:
version "1.0.22"
resolved "https://registry.yarnpkg.com/colorsys/-/colorsys-1.0.22.tgz#e08459b297de7d4da4a53c26c3555f5a9609ad88"
resolved "https://registry.npmjs.org/colorsys/-/colorsys-1.0.22.tgz"
integrity sha512-KCqF23oqkOD0IUCTLCl0obwGIMyeGFlNWuJ4oRRVKmawvKQeb3x5UvajVeH9AShZWU9hNaIhjXeTGw3iPNtl/Q==

[email protected]:
Expand Down Expand Up @@ -2191,9 +2191,9 @@ json-parse-even-better-errors@^2.3.0:
integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==

json5@^2.2.1:
version "2.2.1"
resolved "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz"
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
version "2.2.3"
resolved "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonpath@^1.1.1:
version "1.1.1"
Expand Down

0 comments on commit 00fd967

Please sign in to comment.