wf49670 / ppgen

Post-processing generator for DP
6 stars 4 forks source link

Allow unquoted class parameter in .dv, remove redundant getClass() function #83

Closed davem2 closed 9 years ago

davem2 commented 9 years ago

This fix allows .dv statements with an unquoted class parameter such as: .dv class=classname to be properly parsed.

Prior to this change, the function getClass() was used to parse class information in .dv. This function is only used by .dv and is redundant to get_id("class"). This patch removes the redundant function getClass() and uses get_id() in its place (get_id() properly handles unquoted parameters and provides some error handling).

wf49670 commented 9 years ago

Reposting, with additions: If we do this, then we need to fix <sn class="classname">, too, which was implemented that way for consistency with .dv (and .dv was implemented that way for consistency with all the HTML examples at w3schools, though as it turns out the quoting is not necessary if only a single class name is specified).

But given that multiple class names can be used, then if someone says .dv class=abc def instead of .dv class="abc def" we should catch that error, shouldn't we.

In some ways, it's cleaner as currently implemented and documented: you must use quotes.

Of course, there are other cases where we simply say "you must use quotes if the operand contains spaces" and we don't check for the errors in those cases, either. But I'm not sure we should introduce an error possibility in .dv today that doesn't currently have one, and complicate <sn> processing.

davem2 commented 9 years ago

I agree that class parameters should be quoted, it just seemed inconsistent with how parameters are handled in other dot commands. It's OK by me to leave things as they are and require quotes.

From a software design perspective, it would be beneficial to have a consistent command format so that one generalized function could be used for all command parsing. The way things are now, there are inconsistencies between commands in what is allowed and how badly formed commands are handled.

wf49670 commented 9 years ago

I think, at this point, I would prefer to keep the class parameters quoted, though I agree that the inconsistency with the other parms is a bit disturbing.