Comments (8)
I've literally never seen anyone name things with a colon in the middle. Thank you for the interesting case.
I'll put this on the roadmap for the 9.2 release
from marginalia.
Further investigation shows that it can handle vars with colons; it's maps with values that have colons in them that it chokes on:
This is fine: (def trouble:map {:foo "foo"})
This is not fine: (def trouble:map2 {:my-map trouble:map})
from marginalia.
I was able to make a minimal case for this one at the repl:
(require '[marginalia.parser :as p])
(p/parse "{:x y:z}")
=> Map literal must contain even number of forms
from marginalia.
Not sure why this works at the REPL:
(def my-reader (clojure.lang.LineNumberingPushbackReader. (java.io.BufferedReader. (java.io.StringReader. (str "{:f u:y}" "\n")))))
(. clojure.lang.LispReader (read my-reader false :_eof false))
because this is exactly what parse
is doing when it throws the error
see: this code
https://github.com/gdeer81/marginalia/blob/b2d82b1c84bedc4fb89430cea374143c909249c0/src/marginalia/parser.clj#L437
https://github.com/gdeer81/marginalia/blob/b2d82b1c84bedc4fb89430cea374143c909249c0/src/marginalia/parser.clj#L438
gets called by this code to make a LineNumberingPushbackReader just like I did above https://github.com/gdeer81/marginalia/blob/b2d82b1c84bedc4fb89430cea374143c909249c0/src/marginalia/parser.clj#L440
Then this code calls parse*
with that reader https://github.com/gdeer81/marginalia/blob/b2d82b1c84bedc4fb89430cea374143c909249c0/src/marginalia/parser.clj#L445
so (parse "{:foo x:y}")
doesn't work but
(def my-reader (clojure.lang.LineNumberingPushbackReader. (java.io.BufferedReader. (java.io.StringReader. (str "{:f u:y}" "\n")))))
(. clojure.lang.LispReader (read my-reader false :_eof false))
or (parse* my-reader)
works
from marginalia.
I'm running into this too.
While not super common, I've seen symbol names with colons in them in other projects. They're fairly common in Emacs Lisp, where they're often used either for namespacing or for a group of functions that do similar things. For example in emacs-rotate
there's a series of functions like rotate:main-vertical
and rotate:titled
that all rotate your screen layout in different ways.
We're doing something similar in Metabase where we have two functions to fetch "Cards", one to fetch Cards for a Database and another for Cards for a Table. They're named cards:database
and cards:table
, respectively.
from marginalia.
I think #163 would help, just to join the dots here.
from marginalia.
Just a note that I experienced that issue while working on generating an XML for SAML with hiccup.
For example:
(hiccup/html
[samlp:AuthnRequest
{xmlns:samlp "urn:oasis:names:tc:SAML:2.0:protocol"
:ID identifier
:Version "2.0"
:IssueInstant date
:ProtocolBinding "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
:ProviderName sp-id
:IsPassive false
:Destination authorize-uri
:AssertionConsumerServiceURL uri}
[saml:Issuer
{xmlns:saml "urn:oasis:names:tc:SAML:2.0:assertion"}
uri]])
from marginalia.
This is definitely happening because of the custom colon reader introduced in this 2011 commit that handles double-colon-namespaced keywords.
Looks like parser/read-keyword
needs to be smarter, but I'm still thinking about how to do that.
from marginalia.
Related Issues (20)
- Markdown extension for linking to a function in docstrings and comments HOT 1
- chokes on Clojure 1.7.0 HOT 8
- Marginalia waits a long time for agents to shut down HOT 2
- Every 3rd time I run, I get an exception HOT 3
- Explore the use of Instaparse
- Processing reader conditionals broken HOT 9
- Incompatibility in matchSymbol with Clojure 1.9.0-beta1 HOT 4
- lein marg fails under clojure 1.9.* HOT 11
- Does not take into account `:source-paths` HOT 1
- Markdown target HOT 4
- :extend-via-metadata in protocols breaks Marginalia HOT 3
- docco url in README.md HOT 1
- Add instructions for `deps.edn` projects HOT 1
- Transfer to clj-commons? HOT 1
- Make [[docstring-links]] into links HOT 1
- [Idea] Respect .gitignore
- Support blocking search engines (support custom <head> content?) HOT 3
- Update the website link in repo's "About" section HOT 1
- [Idea] Ways to style the docs based on metadata on `def`s HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marginalia.