Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-17-2020, 04:38 AM   #1
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
[Conversion Output] Markdown Output. Test and seek for help.

I create a Markdown Output plugin. This is nothing new, just the function of TXT Output plugin with txt_output_formatting=markdown, and keep_links=True, keep_image_references=True in default. keep_color have been removed for it is a function in textile. I create this, so that I don't need to set them and rename .txt to .md everytime.

I think this can work, but I still have some questions.
  1. How to set opts in function convert? I use setattr, am I right?
  2. How to create output gui that can be uesd in Calibre?
Attached Files
File Type: zip Markdown Output.zip (1.1 KB, 461 views)
The_book is offline   Reply With Quote
Old 04-17-2020, 05:07 AM   #2
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
And, by the way. I think let build-in plugins the same as outer plugin is a better idea. Now they cannot be removed and hard to change.
The_book is offline   Reply With Quote
Old 04-17-2020, 06:00 AM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,853
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
1. yes
2. You implement gui_configuration_widget() in your plugin
kovidgoyal is online now   Reply With Quote
Old 04-17-2020, 09:44 AM   #4
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
Quote:
Originally Posted by kovidgoyal View Post
1. yes
2. You implement gui_configuration_widget() in your plugin
Thanks.
I update this plugin. Now it has gui in convert.
And now it has more questions.

1. It can convert to Markdown when I use ebook-convert.exe try.epub .md but when I use gui, it prints

calibre, version 4.12.0 (win32, embedded-python: True)
Conversion error: Failed: Convert book 1 of 1 (***)

Convert book 1 of 1 (***)
Failed to initialize plugin: u'C:\\Users\\LJT\\AppData\\Roaming\\calibre\\plugi ns\\Markdown Output.zip'
Python function terminated unexpectedly
No plugin to handle output format: md (Error Code: 1)
Traceback (most recent call last):
File "site.py", line 114, in main
File "site.py", line 88, in run_entry_point
File "site-packages\calibre\utils\ipc\worker.py", line 209, in main
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 43, in gui_convert_override
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 25, in gui_convert
File "site-packages\calibre\ebooks\conversion\plumber.py", line 758, in __init__
ValueError: No plugin to handle output format: md

2. I can see gui in convert widget like image_8.png. How to remove formatting and keep text color?

3. Preference->Output options do not have markdown output. What can I do?
Attached Thumbnails
Click image for larger version

Name:	image_8.png
Views:	277
Size:	19.3 KB
ID:	178476  
Attached Files
File Type: zip Markdown Output.zip (4.9 KB, 263 views)
The_book is offline   Reply With Quote
Old 04-17-2020, 10:11 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,853
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Thats because your plugin is failing initialization

Failed to initialize plugin: u'C:\\Users\\LJT\\AppData\\Roaming\\calibre\\plugi ns\\Markdown Output.zip'
kovidgoyal is online now   Reply With Quote
Old 04-17-2020, 10:15 AM   #6
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
Quote:
Originally Posted by kovidgoyal View Post
Thats because your plugin is failing initialization

Failed to initialize plugin: u'C:\\Users\\LJT\\AppData\\Roaming\\calibre\\plugi ns\\Markdown Output.zip'
But ebook-convert cli works well. I can not understand why.
The_book is offline   Reply With Quote
Old 04-17-2020, 10:18 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,853
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Run calibre in debug mode (right click preferences button) and you will get more information
kovidgoyal is online now   Reply With Quote
Old 04-17-2020, 10:42 AM   #8
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
Quote:
Originally Posted by kovidgoyal View Post
Run calibre in debug mode (right click preferences button) and you will get more information
After checking, it happens in src\calibre\customize\ui.py line 713
Code:
    for zfp in list(external_plugins) + builtin_plugins:
        try:
            if not isinstance(zfp, type):
                # We have a plugin name
                pname = zfp
                zfp = os.path.join(plugin_dir, zfp+'.zip')
                if not os.path.exists(zfp):
                    zfp = external_plugins[pname]
            try:
                plugin = load_plugin(zfp) if not isinstance(zfp, type) else zfp
            except PluginNotFound:
                continue
            if perf:
                st = time.time()
            plugin = initialize_plugin(plugin, None if isinstance(zfp, type) else zfp)
            if perf:
                times[plugin.name] = time.time() - st
            _initialized_plugins.append(plugin)
        except:
            print('Failed to initialize plugin:', repr(zfp))
            traceback.print_exc()
            if DEBUG:
                traceback.print_exc()
with
Quote:
Traceback (most recent call last):
File "D:\workplace\program\open-sourse\calibre-src\src\calibre\customize\ui.py", line 703, in initialize_plugins
File "D:\workplace\program\open-sourse\calibre-src\src\calibre\customize\ui.py", line 61, in load_plugin
File "D:\workplace\program\open-sourse\calibre-src\src\calibre\customize\zipplugin.py", line 203, in load
File "importlib\__init__.py", line 37, in import_module
File "D:\workplace\program\open-sourse\calibre-src\src\calibre\customize\zipplugin.py", line 185, in load_module
File "calibre_plugins.markdown_output.__init__", line 3, in <module>
File "D:\workplace\program\open-sourse\calibre-src\src\calibre\customize\zipplugin.py", line 185, in load_module
File "calibre_plugins.markdown_output.markdown_outp ut", line 3, in <module>
File "D:\workplace\program\open-sourse\calibre-src\src\calibre\customize\zipplugin.py", line 185, in load_module
File "calibre_plugins.markdown_output.ui", line 1, in <module>
File "D:\workplace\program\open-sourse\calibre-src\src\calibre\gui2\convert\txt_output.py", line 10, in <module>
ImportError: cannot import name Widget

Last edited by The_book; 04-17-2020 at 10:45 AM.
The_book is offline   Reply With Quote
Old 04-17-2020, 10:52 AM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,853
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Move your import
at calibre_plugins.markdown_output.ui", line 1, in <module>

to inside the function where it is actually used.
kovidgoyal is online now   Reply With Quote
Old 04-17-2020, 11:03 AM   #10
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
Quote:
Originally Posted by kovidgoyal View Post
Move your import
at calibre_plugins.markdown_output.ui", line 1, in <module>

to inside the function where it is actually used.
Thanks. Now it works well. I update it.
Attached Files
File Type: zip Markdown Output.zip (4.9 KB, 254 views)
The_book is offline   Reply With Quote
Old 04-18-2020, 09:23 AM   #11
The_book
Zealot
The_book began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
By adding
Code:
class TXTUIForm(Ui_Form):
    def setupUi(self, Form):
        super(TXTUIForm, self).setupUi(Form)
        def delete(layout, widget):
            layout.removeWidget(widget)
            widget.deleteLater()
        delete(self.gridLayout,self.label_4)
        delete(self.gridLayout,self.opt_txt_output_formatting)
        delete(self.verticalLayout,self.opt_keep_color)
I remove formatting and keep text color in GUI
Attached Files
File Type: zip Markdown Output.zip (5.2 KB, 263 views)
The_book is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Conversion Output] KFX Output jhowell Plugins 1493 03-21-2024 09:34 AM
[Conversion Output] KePub Output Plugin jgoguen Plugins 551 07-18-2023 06:22 AM
Adding TOC anchor links to Markdown/TXT output maf_jclark Conversion 2 01-17-2014 10:20 PM
Unexpected output from Markdown conversion to ePub Agama Conversion 5 11-25-2012 08:58 AM
Test oeb2mobi output for me? llasram Kindle Formats 60 01-08-2009 02:13 PM


All times are GMT -4. The time now is 05:52 AM.


MobileRead.com is a privately owned, operated and funded community.