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

Page broken if first headline is hidden #8

Closed
Sypwn opened this issue Jan 22, 2021 · 1 comment
Closed

Page broken if first headline is hidden #8

Sypwn opened this issue Jan 22, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Sypwn
Copy link

Sypwn commented Jan 22, 2021

If the first headline on a page is hidden, the page layout breaks.

The following page:

<ifauth @restricted_group>
====== Hidden ======
Hidden content.
</ifauth>

====== Public ======
Not hidden content.

displays like this for users not in restricted_group:
image

Release 2020-07-29 "Hogfather"
Default dokuwiki template

@5p4k 5p4k self-assigned this Feb 7, 2023
@5p4k 5p4k added the bug Something isn't working label Feb 7, 2023
@5p4k
Copy link
Member

5p4k commented Feb 8, 2023

So I've dug through this, and the problem occurs in the following scenario: the first header of the page is enclosed in a hidden ifauth block.

I will see if I can get this properly fixed or if I need a workaround. In the meanwhile, to prevent page breakage, do not put the first header inside an ifauth block. You can use any other formatting as long as it's not a header.


Technical details:

The reason is that when the header is processed by the parser and lexer, it calls Doku_Handler.header. Any header opens a new section, thus setting Doku_Handler.status['section'] = true;. When the parser reaches the second header, the second header sees that a section is open and issues a section_close instruction. It looks like this:

[
	["document_start",[]],
		["plugin",["ifauthex",[1," admin"],1,"<ifauth admin>"]],
		["header",["Hidden",3,16]],
		/* This section is opened by the header above */
		["section_open",[3]],
			["p_open",[]],
				["plugin",["ifauthex",[3,"private"],3,"private"]],
				["cdata",[""]],
			["p_close",[]],
			["plugin",["ifauthex",[4,null],4,"<\/ifauth>"]],
		/* Above: </ifauthex>, below: section_close issued by the following header. */
		["section_close",[]], 
		["header",["Visible",3,51]],
		["section_open",[3]],
			["p_open",[]],
				["cdata",["public"]],
			["p_close",[]],
		["section_close",[]],
	["document_end",[]]
]

for the following page:

<ifauth admin>
==== Hidden ====
private
</ifauth>
==== Visible ====
public

At render time, the html renderer writes a </div> tag in place of the section_close command, but there is no section that has been opened, because that command was hidden. Essentially it's because ifauth can break the page hierarchy.

5p4k added a commit that referenced this issue Feb 8, 2023
Issue an extra section_open command when the first section was opened
within the hidden ifauth block, to anticipate the section_close command
that is necessarily going to be part of the document.
@5p4k 5p4k closed this as completed Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants