I just found out (the hard way), that when you have a HTML form with action="", Webkit browsers treat it differently to Firefox and Internet Explorer.
In FF and IE, these two form tags are equivalent:
<form method="post" action="">
<form method="post">
They will both submit the form back to the same page. Safari and Chrome however will send that first form to the default page (index.php, or whatever) - the second form works the same as FF/IE.
I've quickly hacked my code so that anywhere where it would normally print an empty action, it doesn't add an action attribute at all.
This seems very messy and not the best way to be doing things. Can anyone suggest a better method? Also, can anyone enlighten me about why Webkit would do such a thing?
I usually use
<form method='POST' action='?'>
This means the current URL but with no parameters.
The action attribute is required but you can specify an empty URI reference that referes to the current URI:
<form method="POST" action="">
Edit Ok, this actually is a filed bug of WebKit 528+ (see Bug 19884) when an empty URI is used with a specified base URI using the BASE element. In that case WebKit takes the base URI instead of resolving the empty URI from the base URI.
But this is correct behavior according to RFC 3986:
5.1. Establishing a Base URI
The term "relative" implies that a "base URI" exists against which
the relative reference is applied. […]
The base URI of a reference can be established in one of four ways,
discussed below in order of precedence. The order of precedence can
be thought of in terms of layers, where the innermost defined base
URI has the highest precedence. This can be visualized graphically
as follows:
.----------------------------------------------------------.
| .----------------------------------------------------. |
| | .----------------------------------------------. | |
| | | .----------------------------------------. | | |
| | | | .----------------------------------. | | | |
| | | | | <relative-reference> | | | | |
| | | | `----------------------------------' | | | |
| | | | (5.1.1) Base URI embedded in content | | | |
| | | `----------------------------------------' | | |
| | | (5.1.2) Base URI of the encapsulating entity | | |
| | | (message, representation, or none) | | |
| | `----------------------------------------------' | |
| | (5.1.3) URI used to retrieve the entity | |
| `----------------------------------------------------' |
| (5.1.4) Default Base URI (application-dependent) |
`----------------------------------------------------------'
In this case the BASE element with href attribute is a base URI embedded in content. And base URI embedded in content has a higher precedence than URI used to retrieve the entity. So WebKit’s behavior is actually the expected behavior according to RFC 3986.
But in HTML 5 this behavior of an empty URI in form’s action (still a draft) differs from RFC 3986:
If action is the empty string, let action be the document's address.
Note: This step is a willful violation of RFC 3986, which would require base URL processing here. This violation is motivated by a desire for compatibility with legacy content. [RFC3986]
Frankly, an HTML comment after this note in the source code reads:
<!-- Don't ask me why. But that's what IE does. It even treats
action="" differently from action=" " or action="#" (the latter
two resolve to the base URL, the first one resolves to the doc
URL). And other browsers concur. It is even required, see e.g.
http://bugs.webkit.org/show_bug.cgi?id=7763
https://bugzilla.mozilla.org/show_bug.cgi?id=297761
-->
So this is rather a bug originated from Internet Explorer that became a de-facto standard.
The best way in my opinion would be not to omit the action attribute (which would not validate) but to specify the actual action for the form. Is there a reason you are not specifying the action?
I've always used (in PHP)
<form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>">
To get my forms to submit to themselves.
Related
I have a very complex HTML of a website. I want to select multiple groups of elements by relative Xpath. For example:
//div[#class="something] | //span/div | //div/span/div[#class="otherthing"]
Once I have all elements selected I want to exclude some specific elements within the same xpath.
Let's say the xpath above returned 150 elements as a result. I want to exclude the following 3 xpaths which all point to 1 element each. So the end result should be 147 elements found:
//div[#id="menu"]
//div/span/div[#class="something3"]
//body/span/div/span/div[1]
How can I do this within 1 xpath with Xpath 1?
I have tried the solution here, however this only works while you are selecting one group you would like to exclude from: https://stackoverflow.com/a/74615054/12366148
I have also tried multiple ways to combine the 'not' and 'self' commands, however nothing seems to work. I can't use the except operator unfortunately as that only works in Xpath 2.0.
Given <xsl:variable name="ns1" select='//div[#class="something] | //span/div | //div/span/div[#class="otherthing"]'/> and <xsl:variable name="ns2" select='//div[#id="menu"] | //div/span/div[#class="something3"] | //body/span/div/span/div[1]'/>, you can use e.g.
<xsl:variable name="ns1-except-ns2" select="$ns1[count(. | $ns2) != count($ns2)]"/>
if my XPath 1 recollection still works.
You haven't used an XSLT tag so I guess you want
(//div[#class="something] | //span/div | //div/span/div[#class="otherthing"])[count(. | //div[#id="menu"] | //div/span/div[#class="something3"] | //body/span/div/span/div[1]) != count(//div[#id="menu"] | //div/span/div[#class="something3"] | //body/span/div/span/div[1])]
setting up documentation for a plugin.
Can you add tables within a dd tag?
I tried the code below but it wont output as a table I tried with the double space line break technique but nothing either
This doesnt parse the table and just leaves the table syntax as is
Term
: definition
: | Table cell | Table cel | Table cell |
This wont render (note there are two spaces after definition)
Term
: definition
| Table cell | Table cel | Table cell |
my goal is this:
<dl>
<dt>Term</dt>
<dd>
definition
<table>
<!-- table rows and cells here -->
</table>
</dd>
</dl>
Depending on the Markdown implementation you are using either you can't or you need to do three things:
(1) Wrap your table with blank lines
A table is a block level element, just like a paragraph is. Therefore, it needs to be on a line by itself. To accomplish that, you need to include a blank line before the table. There is no need to add two spaces to the preceding line as the blank line already separates the elements and each block-level element will always be on its own line (barring some non-standard CSS which changes that behavior) .
(2) Indent your table
Of course, when you are nesting block level elements inside a list item and those elements do not start in the first line of the list item, you must indent those elements by one level to indicate they are nested. Therefore, the table must be indented by four spaces or one tab.
(3) Add a table header
Except for Kramdown, all implementations which support tables (that I am aware of) require the table to include a header. Otherwise, they do not recognize it as a table.
Example
Try this:
Term
: definition
| Header 1 | Header 2 | Header 3 |
| ---------- | --------- | ---------- |
| Table cell | Table cel | Table cell |
That said, both definition lists and tables are non-standard Markdown and their behavior varies among implementations which support them (not all do). Therefore, YMMV.
In fact, Babelmark demonstrates that the above works for Pandoc, RDiscount, PHP Markdown Extra, and MultiMarkdown (strangely version 5, but not version 6). Note that a few other implementations likely would work as well if they were properly configured. Babelmark only demonstrates default behavior for each implementation.
I am trying to write a bullet list in markdown table, however I am unable to do so. I tried the solutions given here, and here.
I am writing the following table in bitbuckets readme.md file.
| **Date** | **A** | **B**
|:----------:|:-----:|:------:
| 2016 | Something | <ul><li>A</li><li>B</li><li>C</li></ul>
Every row of column B contains a bullet list of 2 items.
How can I achieve this ? What am I missing ? Please let me know. Thanks in advance.
I used the answer given by #Dorgrin in the post mentioned as a possible duplicate. Even while using that I was not able to get a list displayed. What I was shown was html code as plain text in the third column which is not the intended effect.
Bitbucket is lagging behind on supported features. Apparently they allow html in markdown README files, but they decided not to support it in snippets.
I say "apparently" because I just tried it, and it doesn't even work. See this repo.
I decided to ask them a question about this. You can follow further developments here
On a more positive note, what you had works well on Github as you can see here:
| **Date** | **A** | **B**
|:----------:|:-----:|:------:
| 2016 | Something | <ul><li>A</li><li>B</li></ul><ul><li>C</li></ul> |
<script src="https://gist.github.com/smac89/bc0ff6c7e41396293367b00df626317b.js"></script>
You can mimic the visual affect of a bulleted lists in a markdown table with the ascii character • and the <br> tag for a line break.
| | Apples | Oranges |
|-----------|--------|---------|
|attributes | • color: red <br> • shape: round | • color: orange <br> • shape: round |
|tasty | yes | yes |
Renders like this
I think this keeps the table clean of the html clutter from using the <li> and <ol>/<ul> tags.
If I want to show [<][>] symbols within a paragraph in html page, entity name is required.
So in a web search I found < for < and > for > but the problem is I searched a lot and still found no entity name for [ and ].
Can anyone help me how to show [ ] inside a paragraph?
Just type [ or ].
They have no special meaning in HTML
They appear in the ASCII character set
They appear on standard keyboards
There is no need to use an entity for them.
HTML 5 defines [ and ] if you really want to use 7 times as many bytes as you need though.
Right and left square bracket [ ] don't have HTML entity name by default, but they are included in HTML5 as [ & ] (as #Quentin point out)
If it's require, you can use the entity decimal equivalent, or unicode if you'r using javascript to include them. (cross-browser) or the entity name asigned in HTML5 if you are goint to work only in modern browsers.
Example: http://www.fileformat.info/info/unicode/char/5b/browsertest.htm
decimal visual named Unicode
HTML Entity | [ | [ | [ | U+005B
HTML Entity | ] | ] | ] | U+005D
HTML Entity | < | < | < | U+003C
HTML Entity | > | > | > | U+003E
further reading and good reference for this... http://www.fileformat.info/
If you want to display [<][>] in your p tag you can do it as follows
<p>[<][>]</p>
I have made no secret of my disdain for BBCode and support for more readable text-to-HTML converters like Markdown, which is what SO uses. "Canonical" Markdown however doesn't have a syntax to define tables. So, I am trying to come up with an extension that does just that.
Above all, it should be easy to read and write. Of course it also shouldn't be conflict with existing Markdown syntax. PHP Markdown has syntax for tables that looks like:
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
For some reason, this strikes me as "not enough enough" (mainly because it looks a little too verbose). Does anyone know of a Markdown dialect with a nicer syntax? You are welcome to write your own as well.
Bonus points if it's not extraordinarily difficult to parse but still flexible enough to handle alignments (horizontal and vertical), table headers and possibly colspan and rowspan.
I like Textile's table syntax. It looks like:
|_. a header cell |_. another header |
|_. one more header |=. centered cell |
| regular cell |>. right-aligned cell |
The parser doesn't care about whitespace. This syntax is flexible and avoids the rigidity of syntaxes (like yours, Reddit's, etc.) requiring a "separator" line between a single header row and the rest of the table.