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

Draft for partial file ignoring with tags. #159

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ewoolsey
Copy link

@ewoolsey ewoolsey commented Aug 8, 2023

I'm a DND dungeon master and often find myself wanting to hide only some information within a file. Here is an example of how it could look.

# Interesting Title

Here is some information I want to be exported.

%% BEGIN-EXPORT-IGNORE %%
Here is some information I want hidden.
%% END-EXPORT-IGNORE %%

Here is some other public info.

This is a draft PR. I'm just looking for a go-ahead from the maintainer so I can clean this up, add tests, and add the relevant flags to the cli.

@ewoolsey
Copy link
Author

ewoolsey commented Aug 8, 2023

#158

@zoni
Copy link
Owner

zoni commented Aug 9, 2023

Aside from my commentary on #158, it should be possible to implement this entirely through postprocessors, as opposed to adding some form of preprocessing instead.

I probably have some examples of dropping sections of markdown based on encountered elements in the markdown event stream, if you need them.

@ewoolsey
Copy link
Author

ewoolsey commented Aug 9, 2023 via email

@ewoolsey
Copy link
Author

ewoolsey commented Aug 9, 2023 via email

@epsilonhalbe
Copy link
Contributor

epsilonhalbe commented Sep 16, 2023

just my 2cents

I would go for something like

```no-hugo-export
secret content
```

using the existing markdown code fence syntax than introducing a new one

or

```spoiler
secret content
```

and working on the hugo side to hide those spoilers - I trust my players to not read them ;-)

@ewoolsey
Copy link
Author

ewoolsey commented Oct 5, 2023

just my 2cents

I would go for something like

secret content

using the existing markdown code fence syntax than introducing a new one

or

secret content

and working on the hugo side to hide those spoilers - I trust my players to not read them ;-)

The triple back tick makes the content look different for me though, which I don't want. It should be completely invisible in obsidian read mode.

@ewoolsey
Copy link
Author

ewoolsey commented Oct 5, 2023

@zoni any thoughts on accepting this using a preprocessor? I truly think this is the correct approach. (see my reasons above).

@zoni
Copy link
Owner

zoni commented Oct 6, 2023

I'm sorry, but unfortunately no, this does not feel like the right approach to me. I'm not convinced of the necessity or value of preprocessors in general, and for this specific use-case, it definitely does not feel like the right approach. There are many edge-cases that this will not work correctly with.

Consider for example the following Markdown, which might be written as help documentation as part of this PR:

# Ignoring sections

The following syntax block may be used to ignore content while exporting:

```
%% BEGIN-EXPORT-IGNORE %%
This is ignored
%% END-EXPORT-IGNORE %%
```

Your naive regex-based approach will omit this, leaving an empty code block which is incorrect behavior. Content within code blocks should be left as-is.

This is just a simple example, but there are more situations like this that will crop up when doing pure text-based processing, instead of building on top of the Markdown event structure.

@ewoolsey
Copy link
Author

ewoolsey commented Oct 6, 2023

I'm sorry, but unfortunately no, this does not feel like the right approach to me. I'm not convinced of the necessity or value of preprocessors in general, and for this specific use-case, it definitely does not feel like the right approach. There are many edge-cases that this will not work correctly with.

Consider for example the following Markdown, which might be written as help documentation as part of this PR:

# Ignoring sections

The following syntax block may be used to ignore content while exporting:

%% BEGIN-EXPORT-IGNORE %%
This is ignored
%% END-EXPORT-IGNORE %%

Your naive regex-based approach will omit this, leaving an empty code block which is incorrect behavior. Content within code blocks should be left as-is.

This is just a simple example, but there are more situations like this that will crop up when doing pure text-based processing, instead of building on top of the Markdown event structure.

I'm not sure I understand your example? Of course it would omit that, that's the point is it not? There is no reason to not omit something just because it's inside a code block. There are many valid reasons why you might want to do that.

Anyhow if you disagree I understand, although I really do feel a preprocessor is the right call here. Feel free to give it a shot using the markdown events when you have some time and let me know if you think that solution is better. I did give that a go and found it to be quite overburdensome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants