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

Spurious SAM parser warning: Unannotated phrase found: #205

Open
0x8000-0000 opened this issue Feb 10, 2020 · 4 comments
Open

Spurious SAM parser warning: Unannotated phrase found: #205

0x8000-0000 opened this issue Feb 10, 2020 · 4 comments

Comments

@0x8000-0000
Copy link

Considering this input:

$ cat test_phrase_condition.sam 
!annotation-lookup: case insensitive
!smart-quotes: on

example: Title

    section:(?some=time)
        {Hard}(?when=weekday){Easy}(?when=weekend) day ahead!
        {Pack the cooler!}(?when=weekend)

Produces this:

$ python3 ${HOME}/tools/sam/samparser.py html test_phrase_condition.sam


SAM parser information: Parsing /home/fiucha/tmp/test_phrase_condition.sam
SAM parser warning: Unannotated phrase found: {Hard} If you are trying to insert curly braces into the document, use \{Hard}.
SAM parser warning: Unannotated phrase found: {Easy} If you are trying to insert curly braces into the document, use \{Easy}.
SAM parser warning: Unannotated phrase found: {Pack the cooler!} If you are trying to insert curly braces into the document, use \{Pack the cooler!}.
Using css: None
Process completed with 0 errors.
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset = "UTF-8">
</head>
<body>
<div class="example">
<h1 class="title">Title</h1>

<div class="section" data-conditions="some=time">
<p class="p"><span class="phrase" data-conditions="when=weekday">Hard</span><span class="phrase" data-conditions="when=weekend">Easy</span> day ahead! <span class="phrase" data-conditions="when=weekend">Pack the cooler!</span></p>
</div>
</div>
</body>
</html>%                                 

The warning seems spurious since the phrases are clearly annotated - the conditions are present in the output.

@mbakeranalecta
Copy link
Owner

What is happening here is that SAM makes a distinction between annotations and attributes. Annotations are for semantic markup that describes the what the content means. Annotations are for management doman markup that describes how it is to be processed. Attributes are denoted with symbol prefixes. Annotations are not. So the warnings are correct, there are no annotations on those phrases, just attributes.

This is certainly one of the less obvious parts of the SAM language design. It is a reflection of the fact that SAM was designed to support semantic markup with lightweight syntax, so the semantic approach is favored over the use of management domain attributes at every turn. (Same argument as in the case of attributes on records.)

Could this be better flagged to the user? Certainly.

Is it an appropriate thing to warn the user about at all? Yes. Because of annotation lookup, it is important to raise a warning for unannotated phrases.

Is the distinction between annotations and attributes important? Yes, if for no other reason than annotation lookup (which is a big timesaver) appropriately works for annotations and not for attributes.

Should phrases with attributes but no annotations raise this warning. Yes, because there is the possibility that the user was relying on annotation lookup and no matching annotations were found.

Could it be worded better (or a different wording be chosen in these cases)? Maybe.

@0x8000-0000
Copy link
Author

What would be a good way to indicate that this is what I mean, and I don't want this particular warning? (sort of like a cast in C/C++?)

@mbakeranalecta
Copy link
Owner

mbakeranalecta commented Feb 10, 2020 via email

@mbakeranalecta
Copy link
Owner

!expect-unannotated-phrases: yes/[no]/with-attributes maybe?

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

No branches or pull requests

2 participants