BeautifulSoup return unexpected extra spaces

I believe this is a bug with Lxml’s HTML parser. Try: from bs4 import BeautifulSoup import urllib2 html = urllib2.urlopen (“http://www.beppegrillo.it”) prova = html.read() soup = BeautifulSoup(prova.replace(‘ISO-8859-1’, ‘utf-8’)) print soup Which is a workaround for the problem. I believe the issue was fixed in lxml 3.0 alpha 2 and lxml 2.3.6, so it could be … Read more

Change button text and action – android development

You can use setTag. So, your code will look like, final Button testButton = (Button) findViewById(R.id.button1); testButton.setTag(1); testButton.setText(“Play”); testButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick (View v) { final int status =(Integer) v.getTag(); if(status == 1) { mPlayer.start(); testButton.setText(“Pause”); v.setTag(0); //pause } else { testButton.setText(“Play”); v.setTag(1); //pause } } }); About setTag

How to find android TextView number of characters per line?

Try this: private boolean isTooLarge (TextView text, String newText) { float textWidth = text.getPaint().measureText(newText); return (textWidth >= text.getMeasuredWidth ()); } Detecting how many characters fit will be impossible due to the variable width of the characters. The above function will test if a particular string will fit or not in the TextView. The content of … Read more

Measuring text width/height without rendering

Please check this. is a solution using canvas function get_tex_width(txt, font) { this.element = document.createElement(‘canvas’); this.context = this.element.getContext(“2d”); this.context.font = font; return this.context.measureText(txt).width; } alert(‘Calculated width ‘ + get_tex_width(“Hello World”, “30px Arial”)); alert(“Span text width “+$(“span”).width()); Demo using EDIT The solution using canvas is not the best, each browser deal different canvas size. Here is … Read more

How to show HTML or Markdown in a SwiftUI Text?

iOS 15 Text now supports basic Markdown! struct ContentView: View { var body: some View { VStack { Text(“Regular”) Text(“*Italics*”) Text(“**Bold**”) Text(“~Strikethrough~”) Text(“`Code`”) Text(“[Link](https://apple.com)”) Text(“***[They](https://apple.com) ~are~ `combinable`***”) } } } Result: Update: If you store markdown as a String, it won’t render — instead, set the type to be LocalizedStringKey. struct ContentView: View { @State … Read more

How to reduce the gap between navigation icon and toolbar title?

Add app:contentInsetLeft=”0dp” app:contentInsetStart=”0dp” app:contentInsetStartWithNavigation=”0dp” to the ToolBar. Complete Code : <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:background=”?attr/colorPrimary” app:titleTextAppearance=”@style/Toolbar.TitleText” app:popupTheme=”@style/AppTheme.PopupOverlay” app:contentInsetLeft=”0dp” app:contentInsetStart=”0dp” app:contentInsetStartWithNavigation=”0dp” />

How can I align text directly beneath an image?

Your HTML: <div class=”img-with-text”> <img src=”https://stackoverflow.com/questions/1225130/yourimage.jpg” alt=”sometext” /> <p>Some text</p> </div> If you know the width of your image, your CSS: .img-with-text { text-align: justify; width: [width of img]; } .img-with-text img { display: block; margin: 0 auto; } Otherwise your text below the image will free-flow. To prevent this, just set a width to … Read more