Skip to content

Commit

Permalink
[md_processor] Fixed bug in #parseCaptionText cutting off last captio…
Browse files Browse the repository at this point in the history
…n character when no delimeters are specified. Fixed bug in #parseSize if passed text is falsey.
  • Loading branch information
bicarlsen committed Mar 2, 2022
1 parent 35495e0 commit 7a38342
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Empty file added build.md
Empty file.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-image-caption",
"name": "Image Caption",
"version": "0.0.10",
"version": "0.0.11",
"minAppVersion": "0.13.19",
"description": "Add captions to images.",
"author": "Brian Carlsen",
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": "obsidian-image-caption",
"version": "0.0.10",
"version": "0.0.11",
"description": "Add captions to images in Obsidian.",
"main": "main.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/md_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function parseCaptionText( text: string, delimeter: string[] ): string | null {
end_delim = '';

start = 0;
end = text.length - 1;
end = text.length;
}
else if ( delimeter.length == 1 ) {
// single delimeter character
Expand Down Expand Up @@ -182,6 +182,10 @@ function parseCaptionText( text: string, delimeter: string[] ): string | null {
* or undefined if not found.
*/
function parseSize( text: string ) {
if ( ! text ) {
return undefined;
}

const size_pattern = /(\d+)x(\d+)/i;
const match = text.match( size_pattern );
if ( ! match ) {
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.0.11": "0.13.19",
"0.0.10": "0.13.19",
"0.0.9": "0.12.19",
"0.0.8": "0.12.19",
Expand Down

0 comments on commit 7a38342

Please sign in to comment.