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
[ #3366 ] File extension for output of HTML backend #3367
Conversation
This is a work in progress, don't merge right now. |
@ice1000 Neat! For your particular question, I think the file extension for the links should be However, I think we should think through at least one use case before developing this further. For instance: Scenario A: Blogpost
Currently Agda will uniformly apply the same behavior to all files reachable from the given module, which prevents us from having different highlighting and file extension behavior for each module in the project. Perhaps those of you who expressed interest in #3313 (@UlfNorell @gallais @asr @andreasabel and @nad ) and/or plan to use Agda on Markdown files can clarify your use cases, and see if |
Does Agda save information like whether a file is a lagda file? |
Not that I know of… On the other hand, many internal structures (names, tokens, …) are annotated with Once you have the filename, it is easy to get the extension, and from there the HTML module can decide what to do. There is already a list of supported literate file extensions in The function |
If this works well, we could even do away with flags altogether, and just have I can't think of a use case where one would want to output an HTML file from a EDIT: Also, it makes things complicated in case A.2 and A.3, because the different files involved would need different values for |
Getting the file type from the file extension in the backend sounds like a hacky and ugly solution for me (although it should probably work). |
Also, I'd recommend simply change the default value of TBH I think the HTML backend + lAtEx frontend is also pointless, but it's still supported, and used a lot in the tests. Other things to be considered:
|
I agree is somewhat hacky. As you say, it will parse the same string twice, which is not very elegant. In any case, I think that parsing the filename twice is by itself is not much of an issue, as it is a cheap operation. What is more important is that the code that derives the file type from the file name is implemented in only one place. Then, even if that code happens to be called twice on the same input, the maintenance burden for the code itself is not increased.
The difficulty is that the most sensible default value would change depending on the file type (e.g. One big reason for having the
We'll see if we have 0, 1 or 2 flags in the end :) |
This is what I mean by maintain burden, imagine we're gonna change the file ext parsing logic, we'll have to modify two places. We should follow the DRY (don't repeat yourself) rule in software engineering |
I like this idea! |
I prefer |
Agreed, (I'll now keep playing my Apple-esque role of removing options from the user and making everything work magically). I think the file extension should also be automatic by default, so To avoid another flag, the extension produced by the HTML back-end can also be determined by
Right. So then we can have the parsing logic implemented only in one place (for example, the literate parsing module), and then called again on each filename from the HTML back-end. Then we could stay DRY (at least, code-wise) even if each filename is parsed more than once. |
Don't forget we support rst as well. |
Yes, this sounds better to me, but I still wonder if there's some way to store the information. We can get some extra benifits like we can use the information in Emacs mode! |
|
Adding such a field to interfaces ( |
I think we test these things because there isn't (yet) an easy way to turn off the HTML tests, and unlike the LaTeX tests the HTML tests run quickly, so no one has bothered to implement a way to turn them off. (And if this combination is supported, then it makes sense to test it.) |
No? |
I've found the related code is really badly written, there's a lot of misleading dead codes and some possible refactoring leftovers. But that's all my personal opinion, I know it may not fit you guys' flavor. Maybe I have some misunderstanding of the code base. Feel free to give any suggestions, I'm very willing to learn from you. |
I'm gonna push a commit after my local changes passes compilation, then tweak the tests. |
valu [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = | ||
valuN Interface a b c d e f g h i j k l m n o | ||
valu [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = | ||
valuN Interface a b c d e f g h i j k l m n o p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this, I'm just following the pattern. I hope I'm doing it correctly.
[] -> valuN AgdaFileType | ||
[0] -> valuN MdFileType | ||
[1] -> valuN RstFileType | ||
[2] -> valuN TexFileType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@vlopezj That's cool! Thanks |
Hi, I see this test failure locally: -\\[\AgdaEmptyExtraSkip]%
-\>[0]\AgdaComment{-- A comment with some TeX ligatures:}\<%
-\\
-\>[0]\AgdaComment{-- --, ---, ?`, !`, `, ``, ', '', <<, >>.}\<%
-\\
-%
-\\[\AgdaEmptyExtraSkip]%
-\>[0]\AgdaFunction{Θ₁}\AgdaSpace{}%
-\AgdaSymbol{:}\AgdaSpace{}%
-\AgdaPrimitiveType{Set}\AgdaSpace{}%
-\AgdaSymbol{→}\AgdaSpace{}%
-\AgdaPrimitiveType{Set}\<%
-\\
-\>[0]\AgdaFunction{Θ₁}\AgdaSpace{}%
-\AgdaSymbol{=}\AgdaSpace{}%
-\AgdaSymbol{λ}\AgdaSpace{}%
-\AgdaBound{A}\AgdaSpace{}%
-\AgdaSymbol{→}\AgdaSpace{}%
-\AgdaBound{A}\<%
-\\
-%
-\\[\AgdaEmptyExtraSkip]%
-\>[0]\AgdaFunction{a-name-with--hyphens}\AgdaSpace{}%
-\AgdaSymbol{:}\AgdaSpace{}%
-\AgdaSymbol{∀}\AgdaSpace{}%
-\AgdaSymbol{\{}\AgdaBound{A}\AgdaSpace{}%
-\AgdaSymbol{:}\AgdaSpace{}%
-\AgdaPrimitiveType{Set}\AgdaSymbol{\}}\AgdaSpace{}%
-\AgdaSymbol{→}\AgdaSpace{}%
-\AgdaBound{A}\AgdaSpace{}%
-\AgdaSymbol{→}\AgdaSpace{}%
-\AgdaBound{A}\<%
-\\
-\>[0]\AgdaFunction{a-name-with--hyphens}\AgdaSpace{}%
-\AgdaBound{ff--fl}\AgdaSpace{}%
-\AgdaSymbol{=}\AgdaSpace{}%
-\AgdaBound{ff--fl}\<%
-\\
-%
-\\[\AgdaEmptyExtraSkip]%
-\>[0]\AgdaFunction{ffi}\AgdaSpace{}%
-\AgdaSymbol{:}\AgdaSpace{}%
-\AgdaPostulate{String}\<%
-\\
-\>[0]\AgdaFunction{ffi}\AgdaSpace{}%
-\AgdaSymbol{=}\AgdaSpace{}%
-\AgdaString{"--"}\<%
-\end{code}
-Note that the code is indented.
-
-\end{document}
+LATEX_COMPILE_FAILED with pdflatex I don't know what's happening. Can you help? |
Maybe it's just a problem of my installed xElAtEx. Let's see if it still occurs on CI. |
I see -- maybe I don't have a valid pdflAtEx. I'll install one and try later |
I created some tests for the command line flags. Will PR after the merge of this PR |
As you can see the only test failure is caused by the change of the generated file extension. |
4793395
to
1121d4a
Compare
@vlopezj Please review. I see some CI already passed. |
I think it makes sense to refactor the commits before merging, getting rid of commits called "Fix typo" and "Address comments".
Please include the tests right away. |
The tests are already included in this PR. It's because this PR actually breaks existing tests (the one added in #3313), so I just moved all the test related changes here. I'll refractor commits after you guys review this |
Because CI takes hours to build, I don't want to make force pushes to hide success builds |
I suggest that you run (most of) the tests locally: |
I run it before I commit! But CI builds are more convincing. |
@ice1000 Glad to see it passes the CI build.
I didn't fully understand this… Are the tests included already, or do you plan to submit more tests in a future PR? |
It's included |
Perfect |
Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
… `Interface` Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>
@vlopezj I think it's fine to merge right now. |
Since everything is already reviewed, I consider it proper to merge it directly. |
Signed-off-by: ice1000 ice1000kotlin@foxmail.com
Everything is already covered in #3366 except: