GithubHelp home page GithubHelp logo

python-markdownify's Introduction

Pypi version License Pypi Downloads

Installation

pip install markdownify

Usage

Convert some HTML to Markdown:

from markdownify import markdownify as md
md('<b>Yay</b> <a href="http://github.com">GitHub</a>')  # > '**Yay** [GitHub](http://github.com)'

Specify tags to exclude:

from markdownify import markdownify as md
md('<b>Yay</b> <a href="http://github.com">GitHub</a>', strip=['a'])  # > '**Yay** GitHub'

...or specify the tags you want to include:

from markdownify import markdownify as md
md('<b>Yay</b> <a href="http://github.com">GitHub</a>', convert=['b'])  # > '**Yay** GitHub'

Options

Markdownify supports the following options:

strip

A list of tags to strip. This option can't be used with the convert option.

convert

A list of tags to convert. This option can't be used with the strip option.

autolinks

A boolean indicating whether the "automatic link" style should be used when a a tag's contents match its href. Defaults to True.

default_title

A boolean to enable setting the title of a link to its href, if no title is given. Defaults to False.

heading_style

Defines how headings should be converted. Accepted values are ATX, ATX_CLOSED, SETEXT, and UNDERLINED (which is an alias for SETEXT). Defaults to UNDERLINED.

bullets

An iterable (string, list, or tuple) of bullet styles to be used. If the iterable only contains one item, it will be used regardless of how deeply lists are nested. Otherwise, the bullet will alternate based on nesting level. Defaults to '*+-'.

strong_em_symbol

In markdown, both * and _ are used to encode strong or emphasized texts. Either of these symbols can be chosen by the options ASTERISK (default) or UNDERSCORE respectively.

sub_symbol, sup_symbol

Define the chars that surround <sub> and <sup> text. Defaults to an empty string, because this is non-standard behavior. Could be something like ~ and ^ to result in ~sub~ and ^sup^.

newline_style

Defines the style of marking linebreaks (<br>) in markdown. The default value SPACES of this option will adopt the usual two spaces and a newline, while BACKSLASH will convert a linebreak to \\n (a backslash and a newline). While the latter convention is non-standard, it is commonly preferred and supported by a lot of interpreters.

code_language

Defines the language that should be assumed for all <pre> sections. Useful, if all code on a page is in the same programming language and should be annotated with python or similar. Defaults to ''` (empty string) and can be any string.

code_language_callback

When the HTML code contains pre tags that in some way provide the code language, for example as class, this callback can be used to extract the language from the tag and prefix it to the converted pre tag. The callback gets one single argument, an BeautifylSoup object, and returns a string containing the code language, or None. An example to use the class name as code language could be:

def callback(el):
    return el['class'][0] if el.has_attr('class') else None

Defaults to None.

escape_asterisks

If set to False, do not escape * to \* in text. Defaults to True.

escape_underscores

If set to False, do not escape _ to \_ in text. Defaults to True.

escape_misc

If set to False, do not escape miscellaneous punctuation characters that sometimes have Markdown significance in text. Defaults to True.

keep_inline_images_in

Images are converted to their alt-text when the images are located inside headlines or table cells. If some inline images should be converted to markdown images instead, this option can be set to a list of parent tags that should be allowed to contain inline images, for example ['td']. Defaults to an empty list.

wrap, wrap_width

If wrap is set to True, all text paragraphs are wrapped at wrap_width characters. Defaults to False and 80. Use with newline_style=BACKSLASH to keep line breaks in paragraphs.

Options may be specified as kwargs to the markdownify function, or as a nested Options class in MarkdownConverter subclasses.

Converting BeautifulSoup objects

from markdownify import MarkdownConverter

# Create shorthand method for conversion
def md(soup, **options):
    return MarkdownConverter(**options).convert_soup(soup)

Creating Custom Converters

If you have a special usecase that calls for a special conversion, you can always inherit from MarkdownConverter and override the method you want to change. The function that handles a HTML tag named abc is called convert_abc(self, el, text, convert_as_inline) and returns a string containing the converted HTML tag. The MarkdownConverter object will handle the conversion based on the function names:

from markdownify import MarkdownConverter

class ImageBlockConverter(MarkdownConverter):
    """
    Create a custom MarkdownConverter that adds two newlines after an image
    """
    def convert_img(self, el, text, convert_as_inline):
        return super().convert_img(el, text, convert_as_inline) + '\n\n'

# Create shorthand method for conversion
def md(html, **options):
    return ImageBlockConverter(**options).convert(html)
from markdownify import MarkdownConverter

class IgnoreParagraphsConverter(MarkdownConverter):
    """
    Create a custom MarkdownConverter that ignores paragraphs
    """
    def convert_p(self, el, text, convert_as_inline):
        return ''

# Create shorthand method for conversion
def md(html, **options):
    return IgnoreParagraphsConverter(**options).convert(html)

Command Line Interface

Use markdownify example.html > example.md or pipe input from stdin (cat example.html | markdownify > example.md). Call markdownify -h to see all available options. They are the same as listed above and take the same arguments.

Development

To run tests and the linter run pip install tox once, then tox.

python-markdownify's People

Contributors

5yato4ok avatar alexvonb avatar andredelft avatar andrewcrichards avatar biobox avatar brunomiguens avatar carantunes avatar chrispy-snps avatar dmpayton avatar geecastro avatar hozhyi avatar huuyafwww avatar idvorkin avatar inzaniak avatar jiulongw avatar jsm28 avatar jvanasco avatar lqp1 avatar matthewwithanm avatar mvkorpel avatar simonit avatar skoczen avatar tdgroot avatar tjmnmk avatar tlk avatar tlp-red avatar xydxydxyd1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-markdownify's Issues

Option to use URL as link title if not provided

Markdown supports a link title, like [label](http://u.rl "title"). If there is no title attribute in the HTML, it could make sense to want to use the actual URL as the title, so it would show up on mouse hover in certain applications. An option to support this would be appreciated.

Insert line break after image tag

Currently,

<img src="some_url"><h3>Some Headline</h3>

is converted into

![](some_url)### Some Headline

in atx style, which is not valid markdown.

top-level tests directory wrongly grabbed by find_packages()

Hello,

I would like to package python-markdownify for Gentoo Linux, however I encounter a problem: setuptools tries to install the top-level directory "tests". I am not a Python expert, but I think that it could be fixed by specifying the "exclude" parameter of find_packages(). It would restrict the installed package list.

In setup.py, packages=find_packages() could be rewritten as packages=find_packages(exclude=["tests"])).

Autolink fails for a link with underscore

See the following snippet:

from markdownify import markdownify as md
md('<a href="https://community.kde.org/Get_Involved">https://community.kde.org/Get_Involved</a>')
# [https://community.kde.org/Get\\_Involved](https://community.kde.org/Get_Involved)

Commandline entry Point

There should be a way to run this in the terminal without calling python like this:

  • markdownify file.html
  • HTML_Output | markdownify

Both would print to standard output.

Feature request - Option to skip over an element

Using markdownify 0.11.6, and it is working like a charm except for one thing. I'm scraping a site that has a youtube video embedded in an iframe. In this case i need to just it unchanged from out the site had it.

an option like --skip 'iframe' for example would be great. (ideally with some criteria, such as matching an id or regex).

The following change produces the desired outcome. It's obviously just a quick hack, but it demonstrates to the functionality.

in init.py line ~143

        for el in node.children:
            if isinstance(el, Comment) or isinstance(el, Doctype):
                continue
            elif isinstance(el, NavigableString):
                text += self.process_text(el)
            else:
                if el.name == 'iframe':
                    text += self.process_text(el)
                else:
                    text += self.process_tag(el, convert_children_as_inline)

test.html

<p>Need a way to preserve the original html for a given element.</p>
<i>Please don't discard my iframe :) </i>
<div class="ratio ratio-16x9" data-video="">
    <iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" class="border" data-video="" src="https://www.youtube.com/embed/EHfq0miBu8c?modestbranding=0&amp;rel=0&amp;showinfo=0"></iframe>
</div>
<hr />

Produces:

===================


Need a way to preserve the original html for a given element.


*Please don't discard my iframe :)* 

<iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" class="border" data-video="" src="https://www.youtube.com/embed/EHfq0miBu8c?modestbranding=0&amp;rel=0&amp;showinfo=0"></iframe>



---```

modify state of parser object - __getattr__ AttributeError

im using markdownify in a scrapy project

i want to avoid double-parsing, so when markdownify finds html links, these should be returned to scrapy

import markdownify

class CustomMarkdownConverter(markdownify.MarkdownConverter):

    def __init__(self, **options):
        self.__links = set()
        return super().__init__(**options) # BUG super().__init__ must be called first

    def convert(self, html):
        self.__links.clear()
        return super().convert(html)

    def convert_a(self, el, text, convert_as_inline):
        href = el.get("href")
        if href:
            self.__links.add(href) # save link for scrapy recursion
            el["href"] = rewrite_path(href)
        return super().convert_a(el, text, convert_as_inline)

md4html = CustomMarkdownConverter()

html = """<a href="x">y</a>"""
md = md4html.convert(html)
links = md4html.__links

but the last line will call __getattr__

def __getattr__(self, attr):
# Handle headings
m = convert_heading_re.match(attr)
if m:
n = int(m.group(1))
def convert_tag(el, text, convert_as_inline):
return self.convert_hn(n, el, text, convert_as_inline)
convert_tag.__name__ = 'convert_h%s' % n
setattr(self, convert_tag.__name__, convert_tag)
return convert_tag
raise AttributeError(attr)

which will throw AttributeError

so, to make markdownify more hackable, can we avoid using __getattr__ for internal lookups?

Tables not converted well.

Here is a test case:

from markdownify import markdownify as md

text="""
<html>
  <body>
    <table>
      <thead>
	<tr>
	  <th>
	    <p>Heading 1</p>
	  </th>
	  <th><p>Heading 2</p>
	  </th>
	  <th><p>Heading 3</p>
	  </th>
	</tr>
      </thead>
      <tbody>
	<tr>
	  <td><div><p>
		This is some text for the first column.
	    </p></div>
	  </td>
	  <td colspan=2>
	    <div><p>
		This is the rest of the columns.
	      </p>
	    </div>
	  </td>
      </tbody>
    </table>
  </body>
</html>
"""

print(md(text))

The result cannot be rendered by any markdown engine I know of.

Tables that only use `<tr>` and `<td>` tags do not work

#36 added basic table support, but only for tables that use <th> tags for the first line instead of <td> tags. Tables must look like that:

<table>
    <tr>
        <th>this</th>
        <th>is</th>
        <th>tableheader</th>
    </tr>
    <tr>
        <td>this</td>
        <td>is</td>
        <td>normal table data</td>
    </tr>
    <tr>
        <td>this is</td>
        <td>normal table data</td>
        <td>too</td>
    </tr>
</table>

which results in:

| this | is | tableheader |
| --- | --- | --- |
| this | is | normal table data |
| this is | normal table data | too |

A html table that only uses <td> flags results in a markdown file that looks like that:

| this | is | tableheader |
| this | is | normal table data |
| this is | normal table data | too |

which will not be rendered correctly because the dashed line below the header row is missing.

<b></b> without training space

Hi!

Sorry for spamming comments on your great project! I found that

<b>foo </b>bar

gets translated to

**foo **bar

which gets rendered as

**foo **bar

but should render as

foo bar

This one requires more than one change:

  • Removing the trailing (and leading, for that matter) spaces inside an inline tag (not only <b>)
  • If a leading space was removed, add as space before the opening **
  • If a trailing space was removed, add a space after the closing **

If you don't see any problems with this change, I would create a PR with tests.

Best!
Alex

Issue with line-breaks tags

Hi,

I'm facing an issue with line-breaks tags when they are written like <br/> instead of <br>.

Considering this simple example:

>>> import markdownify
>>> markdownify.markdownify("<p>11111<br>22222<br>33333<br/>44444<br><55555</p>", heading_style=markdownify.ATX)

Expected:

'11111  \n22222  \n33333  \n44444  \n55555 \n\n'

Actual:

'11111  \n22222  \n33333  \n\n\n'

My workaround is to .replace('<br/>','<br>') but it's a little pity...

Could you fix this in a future release?

Regards,

Don't escape characters when between backticks

If i'm understanding the spec correctly we shouldn't have to escape for example underscores when the value is between a backticks.

eg.

`this_should_not_escape` -> `this\_should\_not\_escape`

Extra whitespace added when block elements are separated by newlines

When the input HTML contains newlines between block elements, extra whitespace is being injected.

For example:

>>> import markdownify
>>> markdownify.markdownify("<h1>First</h1>\n<h2>Second</h2>\n<h3>Third</h3>", heading_style=markdownify.ATX)
'# First\n\n ## Second\n\n ### Third\n\n'

Note that I'm only using ATX-style headers here to help demonstrate the problem.

Exclude comments

Currently markdownify allows to parse comments, might not very common to see comments (<!-- & -->) in HTML however when you're working with someones HTML code anything can happen.

Did write a test to check that:

def test_comments():
    text = md("<!-- This is a comment -->")
    assert text == ""

The test above should pass, however, the response is This is a comment and it shouldn't be.

Possible solutions:

  • Do not parse at all the comments
  • Enable to blacklist or exclude the comments on strip parameters or wtv

Awesome work BTW

Encoding unicode as decimal for Markdown

md = markdownify.markdownify(html, heading_style="ATX")
# substitute any unicode with markdown representation
printable = set(string.printable)
md = ''.join(map(lambda c: c if c in printable else f'&#{ord(c)};', md))

Linting tool flake8 is not a build dependency

Building and installing markdownify should not fetch flake8, which is only used during the development of the package. Per pypa/setuptools#931, tests_require should also be removed, in favor of alternative test runners such as tox. I can offer a hand if migration is desired.

Can you provide an option to disable text escaping?

For example, when I convert <p>INVALID_ERROR_CODE</p>, I got INVALID\_ERROR\_CODE, but I want INVALID_ERROR_CODE.

So I must call text.replace(r'\_', '_'). That's too slow when processing long text.

Can I get any help? Thanks.

Newlines not collapsed from HTML

After 97c78ef was merged, the newlines in the parsed HTML are no longer collapsed into normal spaces, resulting in erroneous line breaks in the output.

import markdownify

print(repr(markdownify.markdownify("""\
continuous
line of
text
""")))

In 0.6.1 the above code outputs 'continuous line of text' like it'd look like when rendered in a browser,
while in 0.6.3 it preserves the newlines and outputs 'continuous\nline of\ntext'
This causes issues when the html is wrapped to some length or linebreaks are used to separate out tags, for example

text before link
<a href="link">link text</a>
continued text

How to include lazy loaded image in converted md document?

HTML that I am trying to parse has img tag like below:

<img loading="lazy" class="sub-img alignleft wp-image-164 size-full" src="http://zerodha.com/varsity/wp-content/uploads/2014/07/equity-icon1.png" alt="equity-icon1" width="131" height="131">

Markdown document fails to render this image. Should I use regex parse to remove loading="lazy" or there is a way to do in markdownify?

Doesn't properly convert image inside table

Take the following html as an example:

<table> <tbody> <tr> <td> <img src="https://avatars.githubusercontent.com/u/57845632?s=400&u=48a7889c50d234959a518020779ae2dd0c1e6546&v=4"> </td> </tr> </tbody> </table>

When running this through markdownify, it for some reason doesn't produce a markdown table, with an image, but simply a table, like this:

\n\n| |\n\n

Why this happens is not yet clear to me.

Support tables

Currently tables are not supported. Would be great to see basic support for

autolink when Goodreads breaks the URL

Goodreads’ RSS feeds hide parts of the link: […]URL: <a href="https://archiveofourown.org/works/21085382" rel="nofollow noopener" target="_blank">https://archiveofourown.org/works/210...</a><br />[…]

Fix:

diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index e15ecd4..36e15e7 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -221,11 +221,17 @@ class MarkdownConverter(object):
         title = el.get('title')
         # For the replacement see #29: text nodes underscores are escaped
         if (self.options['autolinks']
-                and text.replace(r'\_', '_') == href
                 and not title
                 and not self.options['default_title']):
-            # Shortcut syntax
-            return '<%s>' % href
+            rtext = text.replace(r'\_', '_')
+            if rtext.endswith('...') and rtext.startswith('http'):
+                # Goodreads-shortened link?
+                if href.startswith(rtext.rstrip('.')):
+                    # force match
+                    rtext = href
+            if rtext == href:
+                # Shortcut syntax
+                return '<%s>' % href
         if self.options['default_title'] and not title:
             title = href
         title_part = ' "%s"' % title.replace('"', r'\"') if title else ''

ASTERISK instead of * for invalid HTML

I have the weird case with 0.11.5 now, that in the output, all * chars (also those used for marking a text portion as bold) just output ASTERISK instead, resulting in texts like this:

input (yes, I know, this is VERY messy and invalid HTML, but this is coming from a messy CMS I want to clean up):

<h2 class="">
<div class="s-component-content s-font-title">
<h2>
<p style="font-size: 130%;">
<strong>Experience</strong>
</p>
</h2>
</div>
</h2>

output:
* ASTERISKASTERISKExperienceASTERISKASTERISK

But subsequently even bolding does not work anymore:

Input
<p>Normal <strong>bold</strong> text.</p>
Output
Normal ASTERISKASTERISKboldASTERISKASTERISK text.

Is there any way to circumvent this using markdownify? Or any way to preprocess/postprocess these cases using this script?

Should the <scripts> be rendered?

Basic exemple:

import markdownify
print(markdownify.markdownify('<script>console.log(1+1)</script>'))

Output:

'console.log(1+1)'

Is this the expected behavior?

chomp optional?

I know we should not remove the chomp as it is might cause issues.

However, I'm using markdownify to parse some HTML to Markdown on some crawlers and so there's a lot of websites that uses the following format:

<b>Text with space inside </b>rest pf the text without space

instead of:

<b>Text with space inside</b> rest of the text without space

It is minor yes, although causes problems due to the parse gets like below and therefore the markdown reader can't read the text as bold:
**Text wit space inside**rest of the text without space

The solution might be adding an option to disallow the chomp. LMK what you'll think.

Line wrapping

Any chance of adding line wrapping to generated markdown with a line length option, say put a newline by default at 79 chars

Command Line Error

Hi,
I stumbled across this script, thanks for publishing this. I tried it on a HTML file with the following command, but can't interpret the error. I'm on a Mac with homebrew / python3.

markdownify test.html > test.md

Traceback (most recent call last):
  File "/opt/homebrew/bin/markdownify", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/main.py", line 61, in main
    print(markdownify(**vars(args)))
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 395, in markdownify
    return MarkdownConverter(**options).convert(html)
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 97, in convert
    return self.convert_soup(soup)
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 100, in convert_soup
    return self.process_tag(soup, convert_as_inline=False, children_only=True)
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 143, in process_tag
    text += self.process_tag(el, convert_children_as_inline)
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 143, in process_tag
    text += self.process_tag(el, convert_children_as_inline)
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 143, in process_tag
    text += self.process_tag(el, convert_children_as_inline)
  [Previous line repeated 16 more times]
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 148, in process_tag
    text = convert_fn(node, text, convert_as_inline)
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 181, in convert_tag
    return self.convert_hn(n, el, text, convert_as_inline)
  File "/opt/homebrew/lib/python3.10/site-packages/markdownify/__init__.py", line 268, in convert_hn
    style = self.options['heading_style'].lower()
AttributeError: 'NoneType' object has no attribute 'lower'

Nested List Formatting Issue

Hello,

I am currently experimenting with this library for parsing HTML blog post content from an RSS feed for use on Reddit. While this library does not claim to cover Reddit's version of Markdown, it is overall fairly compatible with a few overrides here and there depending on the desired behavior.

However, an issue I have been running into has to deal with nested lists, particularly unordered lists (but this may apply to ordered lists too). In the Markdown output, nested unordered lists are not being indented properly.

For example, a section toward the bottom of this article is rendered as such in the output, with no indentation:

#### Lost Sector - Master

* Old
+ Small chance of up to two Enhancement Cores.

* New
+ **Two Enhancement Cores** and a **medium chance** at one more.
+ **One Enhancement Prism** and a **medium chance** at one more.

If one indents the lists (the convention I use is 4 spaces), it begins to show properly on Reddit.

#### Lost Sector - Master

* Old
    + Small chance of up to two Enhancement Cores.

* New
    + **Two Enhancement Cores** and a **medium chance** at one more.
    + **One Enhancement Prism** and a **medium chance** at one more.

I wrote a small demonstration/test script that I hope is helpful in reproducing. Requires FeedParser, Beautiful Soup, LXML, and Markdownify 0.11.6.

convert_list needs a trailing linefeed

I'm seeing that code such as
<ul><li>foo</li></ul><p>bar</p>

is being returned as u'* foo\nbar\n\n' when it really needs to be u'* foo\n\nbar\n\n'. Otherwise, the text bar is seen as part of the list when in fact it is a new paragraph and should not be indented.

A fix is changing the method convert_list to end with:

return text + '\n'

Tidy HTML breaks result

On version 0.11.6 when I run:

markdownify("<h2>\n\tHeadline 2 on new line\n</h2>", heading_style="ATX")

I expect this:

## Headline 2 on new line\n\n

but I get this:

'## \n Headline 2 on new line\n\n'

which I believe is a bug.

Whitespace is removed in code

When converting html with <code> blocks the whitespace ends up with a maximum of one space. This unfortunately means anything with python in codeblocks can't be converted :(

I can't convert img.

hi,

When I try to convert url:
https://mp.weixin.qq.com/s?__biz=MzA3MDA4NzM3NQ==&mid=2650790704&idx=1&sn=e9e6c260fc4ecf56858eab457a25cbf3&chksm=86c95c90b1bed5861f96e202c0d9cfe33ac1cb30ef7fd5c50e7b1119f6d29c41ddd896d35752&scene=0&xtrack=1#rd , there's a strange problem, I can't get any right img tags but “”。

some code:

def html_to_md(html):
soup = BeautifulSoup(html, 'html.parser')
div = soup.find(id='js_content')
mdstr = str(div)
mdstr = md(mdstr)
return mdstr

but I use hard code in ipthon nootbook test it, it will be right, code:

html = """

                <p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;font-size: 12px;box-sizing: border-box !important;overflow-wrap: break-word !important;">这里发的指标均是通达信类型电脑版软件,手机软件有的可能不通用,我没是测试过。指标有设置参数的,新手不懂返回公众号菜单下面</span><strong style="max-width: 100%;overflow-wrap: break-word;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;box-sizing: border-box !important;"><span style="max-width: 100%;overflow-wrap: break-word;font-size: 12px;box-sizing: border-box !important;">“</span></strong><span style="max-width: 100%;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;overflow-wrap: break-word;box-sizing: border-box !important;"><span style="max-width: 100%;overflow-wrap: break-word;font-size: 12px;box-sizing: border-box !important;">指标帮助</span></strong></span><strong style="max-width: 100%;overflow-wrap: break-word;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;box-sizing: border-box !important;"><span style="max-width: 100%;overflow-wrap: break-word;font-size: 12px;box-sizing: border-box !important;">”</span></strong><span style="max-width: 100%;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;font-size: 12px;box-sizing: border-box !important;overflow-wrap: break-word !important;">或回复关键字</span><strong style="max-width: 100%;overflow-wrap: break-word;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;box-sizing: border-box !important;"><span style="max-width: 100%;overflow-wrap: break-word;font-size: 12px;box-sizing: border-box !important;">“</span></strong><span style="max-width: 100%;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;overflow-wrap: break-word;box-sizing: border-box !important;"><span style="max-width: 100%;overflow-wrap: break-word;font-size: 12px;box-sizing: border-box !important;">指标帮助</span></strong></span><strong style="max-width: 100%;overflow-wrap: break-word;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;box-sizing: border-box !important;"><span style="max-width: 100%;overflow-wrap: break-word;font-size: 12px;box-sizing: border-box !important;">”</span></strong><span style="max-width: 100%;text-align: justify;color: rgb(136, 136, 136);font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.54px;font-size: 12px;box-sizing: border-box !important;overflow-wrap: break-word !important;">看教程。指标仅作分析参考,切勿当作神器。</span><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;overflow-wrap: break-word;letter-spacing: 0.54px;box-sizing: border-box !important;">说明:</strong></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(0, 82, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;">别人弄出来的,我赶紧给大家分享</span></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(0, 82, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;">这个是分时副图指标,2个公式,新建的引用公式名称必须是:<span style="max-width: 100%;color: rgb(255, 0, 0);font-family: Verdana, Arial, 宋体, sans-serif;font-size: 12px;text-align: start;">FYSJ</span></span></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;overflow-wrap: break-word;min-height: 1em;white-space: normal;font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;background-color: rgb(255, 255, 255);letter-spacing: 0.54px;box-sizing: border-box !important;"><strong style="max-width: 100%;overflow-wrap: break-word;box-sizing: border-box !important;">例图:</strong></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.7485448195576252" data-s="300,640" data-src="https://mmbiz.qpic.cn/mmbiz_png/b6Cc3fW0LaWicdgXKxWHqHKauGQrdJlEtRxBzaJsXRIMGLiaRzFWcnMZ0xS3IIxI8JBDESNYZV2cO6PE0P8OmnoQ/640?wx_fmt=png" data-type="png" data-w="859" style="width: 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/b6Cc3fW0LaWicdgXKxWHqHKauGQrdJlEtRxBzaJsXRIMGLiaRzFWcnMZ0xS3IIxI8JBDESNYZV2cO6PE0P8OmnoQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" alt="图片" data-fail="0"></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.6877777777777778" data-s="300,640" data-src="https://mmbiz.qpic.cn/mmbiz_png/b6Cc3fW0LaWicdgXKxWHqHKauGQrdJlEtZJibV6NlYbIYFbrWCsq4QtleIwjH3CNAxRTicxO3xf239MXjGppzmPJg/640?wx_fmt=png" data-type="png" data-w="900" style="width: 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/b6Cc3fW0LaWicdgXKxWHqHKauGQrdJlEtZJibV6NlYbIYFbrWCsq4QtleIwjH3CNAxRTicxO3xf239MXjGppzmPJg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" alt="图片" data-fail="0"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;background-color: rgb(255, 255, 255);text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 18px;color: rgb(0, 0, 0);box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;">指标源码:</strong></span><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">M5:=MA(C,5);</span></p><p style="text-align: left;"><br></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">MM:MA(C,10);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">MM2:MA(C,10),COLOR80FFFF,LINETHICK2;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">M25:=MA(C,250);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">MM3:IF(MM2&gt;REF(MM2,1),MM2,DRAWNULL),COLORMAGENTA,LINETHICK1;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">搏杀持股线:IF(MM&gt;REF(MM,1),MM,DRAWNULL),COLORRED,LINETHICK2;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">MM55:IF(MM&lt;REF(MM,1),MM,DRAWNULL),COLORGREEN,LINETHICK2;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">A:=(C+O)/2;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">Z:=C&gt;REF(C,1)*1.05;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">D:=C&lt;REF(C,1)*0.95;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">STICKLINE(Z,A,O,1,0),COLORMAGENTA;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">STICKLINE(D,A,O,1,0),COLORFFFF00;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">ZT:=C&gt;REF(C,1)*1.08;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">DT:=C&lt;REF(C,1)*0.92;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">STICKLINE(ZT,C,O,2,0),COLORRED;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">STICKLINE(DT,C,O,2,0),COLORFFFF00;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">ZTT:=C&gt;REF(C,1)*1.093;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">S:=(C+O)/2;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">STICKLINE(ZTT,S,C,0.01,0),COLORYELLOW;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">YS1:=(HIGH+LOW+CLOSE*2)/4;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">RK3:=EMA(YS1,10);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">RK4:=STD(YS1,10);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">RK5:=(YS1-RK3)*100/RK4;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">RK6:=EMA(RK5,5);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">RK7:=EMA(RK6,10);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">涨:=EMA(RK6,10)+100/2-5,COLORRED;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">跌:=EMA(涨,4),COLORWHITE;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">决杀线:MA(C,20),COLORFFFFFF;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">VAR11:=3*SMA((C-LLV(L,55))/(HHV(H,55)-LLV(L,55))*100,5,1)</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">-2*SMA(SMA((C-LLV(L,55))/(HHV(H,55)-LLV(L,55))*100,5,1),3,1);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">黑马线O:=EMA(VAR11,5);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">VAR12:=(黑马线O-REF(黑马线O,1))/REF(黑马线O,1)*100;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">熊线:=100*(HHV(HIGH,60)-CLOSE)/(HHV(HIGH,60)-LLV(LOW,60));</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">T1:=CROSS(黑马线O,熊线) AND 涨&lt;150;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">AA:= CLOSE=OPEN AND HIGH&lt;&gt;LOW&nbsp; OR CLOSE=OPEN AND HIGH/LOW&gt;1.03&nbsp; OR CLOSE=OPEN AND&nbsp; CLOSE=LOW AND&nbsp; CLOSE&lt;&gt;HIGH&nbsp; OR REF(CLOSE,1)/REF(OPEN,1)&gt;1.03 AND&nbsp; CLOSE/OPEN&lt;0.97 AND&nbsp; OPEN&gt;REF(CLOSE,1) AND CLOSE&lt;REF(CLOSE,1)&nbsp; OR OPEN&gt;CLOSE AND OPEN/REF(C,1)&gt;= 1+4/100 AND CLOSE/OPEN&lt;=1-5/100 OR ABS(HIGH-REF(HIGH,1))/HIGH&lt;0.001&nbsp; &nbsp; &nbsp;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">OR OPEN&gt;=CLOSE AND ABS(HIGH-OPEN)&gt;=ABS(OPEN-LOW) OR CLOSE&gt;=OPEN AND ABS(HIGH-CLOSE)&gt;=ABS(CLOSE-LOW) OR OPEN&gt;REF(CLOSE,1) AND OPEN&gt;CLOSE ;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">BB:=CLOSE&gt;=OPEN AND ABS(HIGH-OPEN)&lt;=ABS(OPEN-LOW) OR CLOSE&lt;=OPEN AND ABS(HIGH-CLOSE)&lt;=ABS(CLOSE-LOW);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">CC:=AA OR BB;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">DD:=涨&gt;REF(涨,1) AND C&lt;&gt;O AND C/REF(C,1)&lt;1.099 ;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">王五:=涨&gt;170&nbsp; AND&nbsp; CC AND DD&nbsp; AND COUNT(C/REF(C,1)&gt;1.090 AND C&lt;&gt;O,20)&lt;=4&gt;=5;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">麻子:=涨&gt;170&nbsp; AND COUNT(C/REF(C,1)&gt;1.093,15)&gt;=5 OR BARSLASTCOUNT(C/REF(C,1)&gt;=1.093)&gt;=5 AND C&lt;&gt;O;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">DRAWICON((HIGH-LLV(L,90))/LLV(L,90)*100&gt;120 AND 黑马线O&gt;=REF(黑马线O,1) AND 黑马线O&gt;98 AND C/REF(C,1)&lt;1.099 AND C&lt;&gt;O AND REF(C,1)&lt;&gt;REF(O,1),H+0.5,2);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">DRAWICON(黑马线O&gt;100 AND C&lt;&gt;O AND REF(C,1)&lt;&gt;REF(O,1),H+0.5,2);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">DRAWICON(王五 OR 麻子 AND C&gt;MA(C,5) AND C&gt;MA(C,30) AND MA(C,5)&gt;MA(C,10) AND C&gt;MA(C,60) AND REF(C,1)/REF(C,2)&lt;1.08 AND REF(C,1)&gt;REF(O,1),H+0.5,2);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">K3:= ABS(L-O)&lt;ABS(O-C) AND C/REF(C,1)&gt;1.093&nbsp; AND REF(C,1)/REF(C,2)&lt;1.093 AND REF(C,2)/REF(C,3)&lt;1.093 AND REF(C,3)/REF(C,4)&lt;1.093 AND REF(C,4)/REF(C,5)&lt;1.093 AND REF(C,5)/REF(C,6)&lt;1.093 AND NOT(C=O AND C/REF(C,1)&gt;1.099) ;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">K4:=C/REF(C,1)&gt;1.093 AND V&lt;REF(V,1) AND REF(C,1)/REF(C,2)&lt;1.093&nbsp; AND COUNT(C/REF(C,1)&gt;1.093,20)&lt;3;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">VVR1:=王五 OR 麻子 AND C&gt;MA(C,5) AND C&gt;MA(C,30) AND MA(C,5)&gt;MA(C,10) AND C&gt;MA(C,60) AND REF(C,1)/REF(C,2)&lt;1.08 AND C/REF(C,1)&gt;C/REF(O,1);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">VVR2:=(HIGH-LLV(L,90))/LLV(L,90)*100&gt;120 AND 黑马线O&gt;=REF(黑马线O,1) AND 黑马线O&gt;95 AND C/REF(C,1)&lt;1.099;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">VVR3:=黑马线O&gt;100 AND C&lt;&gt;O AND C/REF(C,1)&lt;&gt;C/REF(O,1);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">VDR:=VVR1 OR VVR2 OR VVR3&nbsp; ;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">VDT:=K3 OR K4 AND COUNT(C/REF(C,1)&gt;1.05,10)&lt;=4 AND SUM(VDR,12)&lt;1;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">DRAWICON(K3 OR K4 AND COUNT(C/REF(C,1)&gt;1.05,10)&lt;=4 AND SUM(VDR,12)&lt;1 AND SUM(VDT,20)&lt;2 ,O,23);</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">DRAWTEXT(K3 OR K4 AND COUNT(C/REF(C,1)&gt;1.05,10)&lt;=4 AND SUM(VDR,12)&lt;1 AND SUM(VDT,20)&lt;2 ,L-0.05,'妖气'),COLORFF00FF;</span></p><p style="text-align: left;"><span style="font-size: 12px;color: rgb(61, 170, 214);">STICKLINE(K3 OR K4 AND COUNT(C/REF(C,1)&gt;1.05,10)&lt;=4 AND SUM(VDR,12)&lt;1 AND SUM(VDT,20)&lt;2 ,S,C,0.005,0),COLORFFFFFF;</span></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: left;box-sizing: border-box !important;overflow-wrap: break-word !important;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;text-align: left;"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);box-sizing: border-box !important;overflow-wrap: break-word !important;"><img class="rich_pages img_loading" data-cropselx1="0" data-cropselx2="578" data-cropsely1="0" data-cropsely2="360" data-ratio="0.6566666666666666" data-s="300,640" data-src="https://mmbiz.qpic.cn/mmbiz_jpg/b6Cc3fW0LaX8Hlib7pqVd3pUVMUFcfbFAicvfGyM9UvSAKhT6RPNxxaX5Kkc6syHDibG6DJicrudOGLuVDic9xrrMbw/640?wx_fmt=jpeg" data-type="jpeg" data-w="600" style="overflow-wrap: break-word; box-sizing: border-box !important; visibility: visible !important; width: 578px !important; height: 380.24px !important;" _width="578px" src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==" crossorigin="anonymous" alt="图片"><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"></p><p style="max-width: 100%;min-height: 1em;letter-spacing: 0.544px;white-space: normal;font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;background-color: rgb(255, 255, 255);text-align: center;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(136, 136, 136);font-size: 14px;box-sizing: border-box !important;overflow-wrap: break-word !important;">长按二维码关注,更多精彩指标每天分享点赞点看能优先接收系统推送的图文消息。</span></p><p><br></p>
            </div>"""

from markdownify import markdownify as md
md(html)

why? I used both 0.65 and 0.72 version .

Issue with converting <a> tag

markdownify fails to convert simple <a> tag with no text.

s = '<a href="https://www.google.com"></a>\n\ntest'
from markdownify import MarkdownConverter
MarkdownConverter().convert(s)
'\n\ntest'

Use markdownify always return TypeError: unhashable type: 'slice'

When i use the markdownify the console always return TypeError: unhashable type: 'slice'

Console:

  File "/media/{}/ubuntuHD/workspace/{}/project/utils/salesforce_util.py", line 152, in index_sf_articles
    html = md(article)
File "/media/{}/ubuntuHD/workspace/{}/project/venv/lib/python3.8/site-packages/markdownify/__init__.py", line 364, in markdownify
    return MarkdownConverter(**options).convert(html)
  File "/media/{}/ubuntuHD/workspace/{}/project/venv/lib/python3.8/site-packages/markdownify/__init__.py", line 94, in convert
    soup = BeautifulSoup(html, 'html.parser')
  File "/media/{}/ubuntuHD/workspace/{}/project//venv/lib/python3.8/site-packages/bs4/__init__.py", line 342, in __init__
    for (self.markup, self.original_encoding, self.declared_html_encoding,
  File "/media/{}/ubuntuHD/workspace/{}/project//venv/lib/python3.8/site-packages/bs4/builder/_htmlparser.py", line 363, in prepare_markup
    dammit = UnicodeDammit(markup, try_encodings, is_html=True,
  File "/media/{}/ubuntuHD/workspace/{}/project//venv/lib/python3.8/site-packages/bs4/dammit.py", line 430, in __init__
    self.detector = EncodingDetector(
  File "/media/{}/ubuntuHD/workspace/{}/project//venv/lib/python3.8/site-packages/bs4/dammit.py", line 264, in __init__
    self.markup, self.sniffed_encoding = self.strip_byte_order_mark(markup)
  File "/media/{}/ubuntuHD/workspace/{}/project/venv/lib/python3.8/site-packages/bs4/dammit.py", line 329, in strip_byte_order_mark
    if (len(data) >= 4) and (data[:2] == b'\xfe\xff') \
TypeError: unhashable type: 'slice'
2021-08-02 17:20:57,609 WARNING indeed.baseapp: Finished running tool with exit code 1 in 6314 ms [in File "/media/{}/ubuntuHD/workspace/{}/project//venv/lib/python3.8/site-packages/indeed/baseapp/meta.py:250, 140066569185088 (MainThread), 89781 (MainProcess)]

And then the script never finish.

The error appears in bs4 (beautifulSoup) from markdownify.

Code:

def index_sf_articles(es_client, language, articles, starting_id):

    id = starting_id
    for article in articles:

        title = strip_title(article["Title"])
        article["Body"] = article.pop("Details__c")
        article["label_names"] = article["MasterVersion"]["Label__c"]
        article.pop("MasterVersion")
        article["Html_Url"] = get_sf_html_url(article["UrlName"], article["Language"])
        article = {k.lower(): v for k, v in list(article.items())}
        html = md(article)
        es_client.index(
            index="self_help_salesforce_articles",
            id=id,
            body=html,
        )
        log.info(
            "Indexed article with language="
            + language
            + " id="
            + str(id)
            + " and title="
            + title
        )
        id += 1

html = md(article) is where i use the markdownify

The stripTitle:

def strip_title(title):
    return title.strip().replace("?", "").replace("\0026", "")

The get_st_html_url

def get_sf_html_url(url_name, language):
    if language in employer_support_3_langs:
        sf_instance = "employerSupport3"
    elif language in employer_support_2_langs:
        sf_instance = "employerSupport2"
    else:
        sf_instance = "employerSupport1"
    return (
        "https://indeed.force.com/"
        + sf_instance
        + "/s/article/"
        + url_name
        + "?language="
        + language
    )

The article is a HTML

If I remove the markdownify and put the article directly after the body= it works normally

Port to Python 3.

According to Pypi and the current setup.py, this is only to be used with Python 2, not yet with Python 3. I'm interested in software that does what this software does, but don't want to mess with Python 2 any longer. So a port to Python 3 would be appreciated!

special characters not converting correctly

Trying to convert HTML to markdown but the special characters in the HTML text are converting to gibberish. For example, £ converts to £ and ' converts to â. I tried looking for a fix but couldn't find any so here am I submitting it as an issue.

Newlines after images

When converting articles containing images with markdownify:

md('<img src="https://example.com/test.jpg><p>Next paragraph</p>')

I get the following result:

![](https://example.com/test.jpg)Next paragraph\n\n

But what I normally expect is:

![](https://example.com/test.jpg)\n\nNext paragraph\n\n

Is it possible to add a flag to put newlines after images, or even make it the default behavior?

ordered list issue

Hello :)

I encountered a probleme markdownifying ordered lists:

given html = '<ol>\n<li>a</li>\n<li>b</li>\n<li>c</li>\n</ol>'

the ol node list is: ['\n', <li>w</li>, '\n', <li>t</li>, '\n', <li>f</li>, '\n']

as bullet = '%s.' % (parent.index(el) + 1),

the result is:

: markdownify(html)
: ' 2. a\n 4. b\n 6. c\n '

<=>

 2. a
 4. b
 6. c

I could preprocess my html input before passing it to markdonify but I'm affraid to loose "meaningfull linebreaks" if such things even exist ^^
I think this might be handled in the library, what do you think?

Thank you !

Space

print(md("<b> asd </b>"))

return

 **asd** 

I expected

** asd **

Pass through tags that look like HTML but aren't

I'm currently trying to create a program to translate Confluence XML to Markdown targeting a particular wiki.
That wiki extends markdown with todo-lists and panels.

If I make a pass to convert to the extensions before calling markdownify structures like:

<panel>
# foo
</panel>

disappear after calling markdownify.

Is there a way to whitelist tags to be passed through to the output?

Handling links for headers

The following code....

from markdownify import markdownify, ATX

clean_html = '''
<a href="https://www.google.com">
<h4>Google Search</h4>
</a>
'''

md_content = markdownify(clean_html, heading_style=ATX)

print(md_content)

generates...

  [#### Google Search](https://www.google.com) 

It should generate the following MD instead, isn't it?

#### [Google Search](https://www.google.com)

Also, there are 2 white spaces in front that are unnecessary which confuses reliable MD readers.

Fixing the unnecessary white spaces in front of headers in ATX style and a better handling of the <a> tag would allow to generate much higher quality MD output for foundational html tag structures.

Thanks!

Sharing a good reference for me: Markdown Reference Guide

Missing license

Hi,

I'm interested in using your module, but I can't find any licensing info. Can you provide one please ?

Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.