Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GO-4162 corrupted links in markdown import #1624

Merged

Conversation

AnastasiaShemyakinskaya
Copy link
Member

https://linear.app/anytype/issue/GO-4162/corrupted-links-in-markdown-import

The problem is that we don't handle cases, when block have more than one markdown besides links. For example link can be also bold or italic.

To fix it

  • I check if text block have more than one markdown
  • Then I go through all marks in text block and change the type of mark to page mention in case it is link to existing page or file.

Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
Copy link

github-actions bot commented Oct 1, 2024

New Coverage 48.7% of statements
Patch Coverage 64.8% of changed statements (46/71)

Coverage provided by /~https://github.com/seriousben/go-patch-cover-action

assert.Equal(t, model.BlockContentTextMark_Object, block.GetText().GetMarks().GetMarks()[1].Type)
})
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сonsider use @deff7's testutil.BuildStateFromAST

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see advantages in using it, because we need just to manipulate text block

@@ -89,3 +89,155 @@ func Test_processFiles(t *testing.T) {
assert.Len(t, fileBlocks, 0)
})
}

func Test_processTextBlock(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using real markdown test data here

testing small internal functions leads to fragile tests and don't cover the whole process of import

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

core/block/import/markdown/import_test.go Outdated Show resolved Hide resolved
Signed-off-by: AnastasiaShemyakinskaya <shem98a@mail.ru>
fileNameToObjectId[snapshot.FileName] = snapshot.Id
}
var found bool
expectedPath := "testdata" + string(filepath.Separator) + "links.md"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use filepath.Join everywhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@AnastasiaShemyakinskaya AnastasiaShemyakinskaya merged commit fd8b1e8 into main Oct 9, 2024
5 checks passed
@AnastasiaShemyakinskaya AnastasiaShemyakinskaya deleted the go-4162-corrupted-links-in-markdown-import branch October 9, 2024 16:03
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants