Skip to content

Commit

Permalink
remove dead code, fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeerickson committed Jul 7, 2022
1 parent 6aeb276 commit 60d1648
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 24 deletions.
5 changes: 5 additions & 0 deletions codedungeon.Toolbox/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

See Plugin [README](https://github.com/NotePlan/plugins/blob/main/codedungeon.Toolbox/README.md) for details on available commands and use case.

## [1.4.0] - 2022-07-07 (@mikeerickson)

- Removed dead code
- Fixed linting errors

## [1.3.1] - 2022-05-24 (@mikeerickson)

- Removed `convertToRtf` as it has been added to NotePlan
Expand Down
2 changes: 1 addition & 1 deletion codedungeon.Toolbox/src/convertToHtml.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
/*-------------------------------------------------------------------------------------------
* Copyright (c) 2021 Mike Erickson / Codedungeon. All rights reserved.
* Copyright (c) 2021-2022 Mike Erickson / Codedungeon. All rights reserved.
* Licensed under the MIT license. See LICENSE in the project root for license information.
* -----------------------------------------------------------------------------------------*/

Expand Down
2 changes: 1 addition & 1 deletion codedungeon.Toolbox/src/convertToRtf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
/*-------------------------------------------------------------------------------------------
* Copyright (c) 2021 Mike Erickson / Codedungeon. All rights reserved.
* Copyright (c) 2021-2022 Mike Erickson / Codedungeon. All rights reserved.
* Licensed under the MIT license. See LICENSE in the project root for license information.
* -----------------------------------------------------------------------------------------*/

Expand Down
3 changes: 1 addition & 2 deletions codedungeon.Toolbox/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*-------------------------------------------------------------------------------------------
* Copyright (c) 2021 Mike Erickson / Codedungeon. All rights reserved.
* Copyright (c) 2021-2022 Mike Erickson / Codedungeon. All rights reserved.
* Licensed under the MIT license. See LICENSE in the project root for license information.
* -----------------------------------------------------------------------------------------*/

export { convertToHtml } from './convertToHtml'
export { convertSelectionToHtml } from './convertSelectionToHtml'
// export { convertToRtf } from './convertToRtf'
export { reorderList } from './reorderList'
1 change: 0 additions & 1 deletion codedungeon.Toolbox/src/reorderList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Licensed under the MIT license. See LICENSE in the project root for license information.
* -----------------------------------------------------------------------------------------*/

import { showMessage } from '../../helpers/userInput'
import CodedungeonToolbox from './support/CodedungeonToolbox'

export async function reorderList(): Promise<void> {
Expand Down
26 changes: 7 additions & 19 deletions codedungeon.Toolbox/src/support/CodedungeonToolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const removeAttributes = (str = '', attrs = []) => {
const reg = /<\s*(\w+).*?>/gm
const reg2 = /\s*(\w+)=\"[^\"]+\"/gm

str = str.replace(reg, (match, i) => {
const result = match.replace(reg2, (match_, i) => {
str = str.replace(reg, (match) => {
const result = match.replace(reg2, (match_) => {
const matchFound = reg2.exec(match_)
if (matchFound) {
return attrs.indexOf(matchFound[1]) >= 0 ? match_ : ''
Expand All @@ -26,8 +26,6 @@ const removeAttributes = (str = '', attrs = []) => {
return str
}

function convertHtmlToRtf(html) {}

export default class CodedungeonToolbox {
markdownToHtml(text = '', options = { removeAttributes: true }) {
const showdownConverter = new showdown.Converter()
Expand All @@ -54,26 +52,17 @@ export default class CodedungeonToolbox {
let richText = html

// Singleton tags
richText = richText.replace(
/<(?:hr)(?:\s+[^>]*)?\s*[\/]?>/gi,
'{\\pard \\brdrb \\brdrs \\brdrw10 \\brsp20 \\par}\n{\\pard\\par}\n',
)
richText = richText.replace(/<(?:hr)(?:\s+[^>]*)?\s*[\/]?>/gi, '{\\pard \\brdrb \\brdrs \\brdrw10 \\brsp20 \\par}\n{\\pard\\par}\n')
richText = richText.replace(/<(?:br)(?:\s+[^>]*)?\s*[\/]?>/gi, '{\\pard\\par}\n')

// Empty tags
richText = richText.replace(/<(?:p|div|section|article)(?:\s+[^>]*)?\s*[\/]>/gi, '{\\pard\\par}\n')
richText = richText.replace(/<(?:[^>]+)\/>/g, '')

// Hyperlinks
richText = richText.replace(
/<a(?:\s+[^>]*)?(?:\s+href=(["'])(?:javascript:void\(0?\);?|#|return false;?|void\(0?\);?|)\1)(?:\s+[^>]*)?>/gi,
'{{{\n',
)
richText = richText.replace(/<a(?:\s+[^>]*)?(?:\s+href=(["'])(?:javascript:void\(0?\);?|#|return false;?|void\(0?\);?|)\1)(?:\s+[^>]*)?>/gi, '{{{\n')
const tmpRichText = richText
richText = richText.replace(
/<a(?:\s+[^>]*)?(?:\s+href=(["'])(.+)\1)(?:\s+[^>]*)?>/gi,
'{\\field{\\*\\fldinst{HYPERLINK\n "$2"\n}}{\\fldrslt{\\ul\\cf1\n',
)
richText = richText.replace(/<a(?:\s+[^>]*)?(?:\s+href=(["'])(.+)\1)(?:\s+[^>]*)?>/gi, '{\\field{\\*\\fldinst{HYPERLINK\n "$2"\n}}{\\fldrslt{\\ul\\cf1\n')
const hasHyperlinks = richText !== tmpRichText
richText = richText.replace(/<a(?:\s+[^>]*)?>/gi, '{{{\n')
richText = richText.replace(/<\/a(?:\s+[^>]*)?>/gi, '\n}}}')
Expand All @@ -96,13 +85,12 @@ export default class CodedungeonToolbox {

// Prefix and suffix the rich text with the necessary syntax
/* eslint-disable prefer-template*/
richText =
'{\\rtf1\\ansi\n' + (hasHyperlinks ? '{\\colortbl\n;\n\\red0\\green0\\blue255;\n}\n' : '') + richText + '\n}'
richText = '{\\rtf1\\ansi\n' + (hasHyperlinks ? '{\\colortbl\n;\n\\red0\\green0\\blue255;\n}\n' : '') + richText + '\n}'

return richText
}

async reorderList(listData = '') {
reorderList(listData = '') {
const workingData = [...listData]

let lineItem = 0
Expand Down

0 comments on commit 60d1648

Please sign in to comment.